changing array values recursively in PHP -


i'm trying change values of array recursevely , examples i've seen in stackoverflow don't fit want far.

basically, want translate boolean string.

foreach($this->data $key=>$value) {     if (is_bool($value))     {         $this->data[$key] = var_export($value, true);     }        } 

this works in first level of array. also, i've tried change values array_walk_recursive no success well.

thanks in advance.

array_walk_recursive() should easily

array_walk_recursive(     $myarray,     function (&$value) {         if (is_bool($value)) {             $value = 'i boolean';         }     } ); 

demo


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -