<?php /*模式修正符:1.作用是扩展正则功能,或者解释正则 2.单个模式修正符就有一个单独的功能,也可以几个组合使用 */ $str='this is a Test'; //模式修正符i:正则匹配不区分大小写 $pat='/test/i'; if(preg_match($pat,$str,$arr)){ echo "正则 $pat 匹配 $str 成功!<br>"; print_r($arr)...
<?php //不用系统提供的系统函数自己写一个函数来实现字符串翻转的功能; $str='847760992@qq.com'; function str($string){ $str_new=''; $count=strlen($string)-1; for($m=$count;$m>=0;$m--){ &n...
<?php //字符串格式化函数 //1.反转字符串函数strrev(); $str='wbc.baidu.com'; echo strrev($str),"<br>";
//2.number_format():以千位分隔符格式化一个数字 $str='1353454359803.33432156'; //后面不加参数,就会去除小数部分输出1,353,454,359,803 echo number_format($str)."<br>"; //加...
<?php //trim()函数:默认功能为去除字符串首尾处的空格(或其它字符),返回一个人新的字符串; $str=" hello world! "; echo "\$str的长度为---".strlen($str)."<br>"; $nstr=trim($str); &n...
<?php //字符串截取函数:substr()和mb_substr(),一般情况下都选择用前者,只有在处理中文字符串时才会用到后者 $str="abcdefg"; $str1=substr($str,0,7); $str2=substr("中国人",0,7); echo $str1."<...
<?php //1.赋值运算符=,+=,-= ......等等用法比较简单,这里主要是练习.=的使用方法和技巧;
//2.整数与浮点数不能直接与字符串相连输出; $a=5; $str="liuren"; $str1="liuyi"; //echo $str.$str1.5;//语法错误,不能直接与数字相连; echo $str.$str1.$a."<br>";
//3.连接输出与双引号单引号共...