扫码关注官方订阅号
像这样: 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中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
简单 正则搞定
<?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来裁剪出来。具体用法可以看手册。看你具体怎么想了
正则表达式也可以做到更复杂的分割