Home  >  Article  >  Backend Development  >  关于STR REPLACE 不能替换多个字符的有关问题 求解

关于STR REPLACE 不能替换多个字符的有关问题 求解

WBOY
WBOYOriginal
2016-06-13 13:20:11897browse

关于STR REPLACE 不能替换多个字符的问题 求解
我用STR REPLACE 替换 例如第一个
echo "$uri/view/".trim(str_replace ( '%0A', '', rawurlencode($line))).'.html
帮%0A 替换成空 这个替换正常 而我现在需要一次性替换多个
代码如下
echo "$uri/view/".trim(str_replace (array("%0A",''),array("%0D",''), rawurlencode($line))).'.html
%0A 替换成空 成功 但是后面的替换%0D 却失效 求解
如何让这个代码 同时替换两个字符呢

------解决方案--------------------
echo "$uri/view/".trim(str_replace (array("%0A","%0D"),"", rawurlencode($line))).'.html
------解决方案--------------------
str_replace (array("%0A",''),array("%0D",''), rawurlencode($line))
=>
strtr (rawurlencode($line), array("%0A"=>'',"%0D"=>''))

Statement:
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