array_map with str_replace

Lizard picture Lizard · Jun 3, 2011 · Viewed 20.1k times · Source

Is it possible to use array_map in conjunction with str_replace without calling another function to do the str_replace?

For example:
array_map(str_replace(' ', '-', XXXXX), $myArr);

Answer

chiborg picture chiborg · Jun 3, 2011

There is no need for array_map. From the docs: "If subject is an array, then the search and replace is performed with every entry of subject, and the return value is an array as well."