Blogger Information
Blog 24
fans 0
comment 0
visits 16394
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常用字符串函数-2018年8月27日
鱼越龙门的博客
Original
851 people have browsed it

今天学习了字符串的一些函数;

代码:

实例

<?php
$str="welcome to china";
echo substr($str,2),'<br>';
echo substr($str,3,6),'<br>';
echo substr($str,-4),'<br>';
echo '<hr>';
$str1="test@163.com";
echo strstr($str1,'@'),'<br>';
echo strstr($str1,'@',true),'<br>';
echo '<hr>';
echo strpos($str,"to");

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<?php
$str='小明在学习php,小明在学习html,小明在学习css';
echo str_replace('php','java',$str),'<br>';
echo str_replace('在','  ',$str),'<br>';
echo str_replace(['php','html','css'],'java',$str),'<br>';
echo str_replace(['php','html','css'],['java','mysql','thinkphp'],$str),'<br>';

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<?php
$st=[
    ['name'=>'jim','grade'=>97],
    ['name'=>'tom','grade'=>47],
    ['name'=>'lily','grade'=>67],
    ['name'=>'Lucy','grade'=>84],
];
usort($st,function ($m,$n){
    return strcmp($m['grade'],$n['grade']);
});
echo var_export($st,true);

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post