像这样: abcde1234 转成 abcd 1234 小白求助...
闭关修行中......
简单 正则搞定
<?php
$str = "abcde1234"; preg_match('/^(\w+)e(\d+)$/i',$str,$matches);
print_r ($matches);
Array ( [0] => abcde1234 [1] => abcd [2] => 1234 )
explode()函数 http://www.w3school.com.cn/php/func_string_explode.asp
<?php $str = "abcde1234"; print_r (explode("e",$str)); Array ( [0] => abcd [1] => 1234 )
在线演示:http://3v4l.org/k7Dap
支持楼上,当然你也可以用strpos查找位置,然后用substr来裁剪出来。具体用法可以看手册。看你具体怎么想了
正则表达式也可以做到更复杂的分割
简单 正则搞定
<?php
$str = "abcde1234";
preg_match('/^(\w+)e(\d+)$/i',$str,$matches);
print_r ($matches);
Array
(
[0] => abcde1234
[1] => abcd
[2] => 1234
)
explode()函数 http://www.w3school.com.cn/php/func_string_explode.asp
在线演示:http://3v4l.org/k7Dap
支持楼上,当然你也可以用strpos查找位置,然后用substr来裁剪出来。具体用法可以看手册。看你具体怎么想了
正则表达式也可以做到更复杂的分割