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'; } } );
Comments
Post a Comment