I've created this function to replace strings in multidimensional arrays.
function replace_in_array($find, $replace, & $array) {
array_walk_recursive($array, function( & $array) use($find, $replace) {
if ($array == $find) {
$array = $replace;
}
});
return $array;
}
For the most part it works. But sometimes it replaces the string where it's not supposed too.
While I run it like this replace_in_array('hello', 'hey', $array) things like this get replaced.
'age' => true, or 'age' => 0
My array has about 300 keys and values. For the most part it works. Just a few get replaced when not supposed too. Any idea what im doing wrong here? Thanks