Home > Backend Development > PHP Tutorial > 怎么动态截掉字符串”1|10,2|11,3|12“中的|和,号之间的部分,包括|

怎么动态截掉字符串”1|10,2|11,3|12“中的|和,号之间的部分,包括|

WBOY
Release: 2016-06-13 12:04:25
Original
939 people have browsed it

如何动态截掉字符串”1|10,2|11,3|12“中的|和,号之间的部分,包括|?
如何用PHP,动态截掉字符串”1|10,2|11,3|12“中的|和,号之间的部分,包括|?
------解决方案--------------------
str_replace(",","",str_replace("
------解决方案--------------------
","",$val)) 替换即可
------解决方案--------------------

$s = "1<br><font color='#FF8000'>------解决方案--------------------</font><br>10,2<br><font color='#FF8000'>------解决方案--------------------</font><br>11,3<br><font color='#FF8000'>------解决方案--------------------</font><br>12";<br />echo preg_replace('/\<br><font color='#FF8000'>------解决方案--------------------</font><br>[^,]+,/', ',', $s);
Copy after login
1,2,3
------解决方案--------------------
12
------解决方案--------------------
<br />$content = '1<br><font color='#FF8000'>------解决方案--------------------</font><br>10,2<br><font color='#FF8000'>------解决方案--------------------</font><br>11,3<br><font color='#FF8000'>------解决方案--------------------</font><br>12';<br />echo preg_replace(array('/\<br><font color='#FF8000'>------解决方案--------------------</font><br>[^,]+,/','/\<br><font color='#FF8000'>------解决方案--------------------</font><br>[^,]+$/'), array(',',''), $content);<br />
Copy after login

1,2,3
------解决方案--------------------
$s = "1<br><font color='#FF8000'>------解决方案--------------------</font><br>10,2<br><font color='#FF8000'>------解决方案--------------------</font><br>11,3<br><font color='#FF8000'>------解决方案--------------------</font><br>12";<br />echo preg_replace('/\<br><font color='#FF8000'>------解决方案--------------------</font><br>[^,]+/', '', $s);
Copy after login
1,2,3

但这并不符合:截掉 
------解决方案--------------------
 和 , 号之间的部分

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