Replace several instances to a char in string
Posted: Thu Mar 10, 2011 6:23 pm
$string = "123-[toB][toB][toB]-567-[toB]-78-[toB][toB]";
// should echo 123-b-567-b-78-b
How can I replace the [toB] into a letter b even it is repeated?
str_replace('[toB]','b', $string);
gives me 123-bbb-567-b-78-bb
but need // 123-b-567-b-78-b
// should echo 123-b-567-b-78-b
How can I replace the [toB] into a letter b even it is repeated?
str_replace('[toB]','b', $string);
gives me 123-bbb-567-b-78-bb
but need // 123-b-567-b-78-b