简体   繁体   English

Str_replace在一个变量中的多个字符串?

[英]Str_replace multiple strings in one variable?

How can I combine the two str_replace to one variable? 如何将两个str_replace组合成一个变量?

$putbhp = str_replace("cc,A","cc,0bhp,A",$whites);

$putbhp = str_replace("cc,M","cc,0bhp,M",$whites);
$putbhp = str_replace(['cc,A', 'cc,M'], ['cc,0bhp,A', 'cc,0bhp,M'], $whites);

If you're stuck with an old version of PHP (< 5.4), substitute the array shorthand with array('val', 'val', 'etc') 如果您遇到旧版本的PHP(<5.4),请将数组替换为array('val', 'val', 'etc')

Demo here - http://codepad.viper-7.com/3HKxV9 在这里演示 - http://codepad.viper-7.com/3HKxV9

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM