How can I replace a set of placeholders on a string with an array of substrings?
My code:
$replaceWith = array('FIAT', 'car');
$message = '{%s} is the best {%s} of the world.';
$finalMessage = str_replace(array_fill(0, count($replaceWith), '{%s}'), $replaceWith, $message);
var_dump($finalMessage);
Outputs:
string 'FIAT is the best FIAT of the world.' (length=35)
Desired Output:
string 'FIAT is the best car of the world.' (length=34)
Thks in advance!