Make string replacements using an associative array
arrays, associative-array, php, replace, string
Solution
Off of the top of my head:
$find = array_keys($list);
$replace = array_values($list);
$new_string = str_ireplace($find, $replace, $string);
Problem
I have an associative array where keys are search strings and values are replacement strings. ``` $list = ['hi' => 0, 'man' => 1]; $string = "hi man, how are you? man is here. hi again." ``` It should produce: ``` $final_string = "0 1, how are you? 1 is here. 0 again." ``` How can I achieve this?