1. Get the string length
$str'abc';$str1='中文';echo strlen($str),'
',strlen($str1); 输出结果:36
2. Find string
//查找字符串首次出现的位置$char'a';$str'abc';$bRet = strpos($str,$char);if($bRetfalse){ echo"$str 中不含有$char ";}else{ echo"$str 中含有$char ";}echo'
'
3. Replace string
//替换字符串str_replace()$str'Good morning';$str1 = str_replace('moring','afternoon',$str);echo$str'
'$str1;输出结果:Good morningGood morning//替换字符串strtr()$str'上车,上课,上班,下车,下课,下班';$str1 = strtr($str,['上'=>'下','下'=>'上']);echo$str,'
',$str1;输出结果:上车,上课,上班,下车,下课,下班下车,下课,下班,上车,上课,上班
4. Intercepting strings
//截取字符串substr(),参数分别为目标字符串,起始位置,截取长度$str'East,west,home is best';echo$str,'
',substr($str,0,4);输出结果:East,west,home is bestEast
5. Splitting a string
//拆分字符串explode()$str'厨子, 戏子, 痞子';$arr = explode(',',$str);echo$str,'
';print_r($arr);输出结果:厨子, 戏子, 痞子Array ( [0] => 厨子 [1] => 戏子 [2] => 痞子 )
6. Merging arrays into strings
$arr=['0'=>'厨子','1'=>'戏子','2'=>'痞子'];$str=implode($arr,';');print_r($arr);echo'
';echo$str;输出结果:Array ( [0] => 厨子 [1] => 戏子 [2] => 痞子 ) 厨子;戏子;痞子
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the PHP processing string, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.