say I have an array in php like this
$info['name'] = 'test %value%';
$info['city'] = 'city test %value%';
$info['other'] = '%value% city test';
all I want to do is loop through this array and replace all the instances of %value% with a supplied string, saving it into the same array.
What would be the best way to do that? :)
Thanks
foreach ($info as $key => $value)
$info[$key] = str_replace('%value%', 'MyValue', $value);
Demo: http://ideone.com/65F3L
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With