php字符串怎么截取

WBOY
Release: 2016-06-13 11:15:00
Original
902 people have browsed it

php字符串如何截取
假设有一个字符串
$addr='甘肃省兰州市电信'
我想取出其中的省和市信息
$p='甘肃省'
$c='兰州市'
怎么操作才能取出?

注:我使用$p = strstr($addr, '省',true); 提示没有第三个参数
有没有其他办法取


------解决方案--------------------
$addr = '甘肃省兰州市电信';<br />preg_match_all('/.+?(?:省<br><font color='#FF8000'>------解决方案--------------------</font><br>市)/', $addr, $r);<br />list($p, $c) = $r[0];<br />echo $p;<br />echo $c;
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template