Reputation: 8836
How can I combine the two str_replace to one variable?
$putbhp = str_replace("cc,A","cc,0bhp,A",$whites);
$putbhp = str_replace("cc,M","cc,0bhp,M",$whites);
Upvotes: 1
Views: 580
Reputation: 164871
$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')
Demo here - http://codepad.viper-7.com/3HKxV9
Upvotes: 3