Replace string in an array with PHP [closed]

Why not just use str_replace without a loop?

$array = array('foobar', 'foobaz');
$out = str_replace('foo', 'hello', $array);

Leave a Comment