javascript - Replacing underscores with spaces PHP -


i want search in array , replace occurrences of underscores spaces , implode array string new line character.

however, i'm facing difficulties in replacing underscores array.

here's code:

$array = array('this_that','is','an','array');    function fixarraykey(&$arr) {     $arr=array_combine(array_map(function($str){return str_replace("_"," ",$str);},array_keys($arr)),array_values($arr));     foreach($arr $key=>$val)     {         if(is_array($val)) fixarraykey($arr[$key]);     } }  fixarraykey($array); print_r($array); 

edit 1:

i want search entries of true , replace yes in same array, optimal solution goal.

i recommend using array_walk_recursive

$array = array('this_that','is','an','array');  array_walk_recursive($array,function(&$v){     $v = str_replace('_',' ',$v); });  print_r($array); 

Popular posts from this blog