1

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);

1 Answer 1

3
$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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.