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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -