Home > Backend Development > PHP Tutorial > 想描红所有123 但是返回的结果却是008,而不是预想的0560708,是哪里出的有关问题呢

想描红所有123 但是返回的结果却是008,而不是预想的0560708,是哪里出的有关问题呢

WBOY
Release: 2016-06-13 12:56:57
Original
1056 people have browsed it

想描红所有123 但是返回的结果却是008,而不是预想的0560708,是哪里出的问题呢?

<?php<br />
$subject=1235612371238;<br />
$word=123;<br />
$pattern="#.*($word).*#sUi";<br />
echo preg_replace($pattern, "0", $subject);<br />
?>
Copy after login



想描红所有123 但是返回的结果却是008,而不是预想的0560708,是哪里出的问题呢?


------解决方案--------------------
<?PHP<br />
$subject=1235612371238;<br />
$word=123;<br />
$pattern="/.*($word).*/sUi";<br />
//echo preg_replace($pattern, "0", $subject);<br />
var_dump(Strtr($subject,Array('123'=>'0')));
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