recursive array_map for php4


/ Published in: PHP
Save to your folder(s)

in php5 use array_walk_recursive


Copy this code and paste it in your HTML
  1. function array_map_recursive($callback, $array) {
  2. $r = array();
  3. if (is_array($array)) {
  4. foreach($array as $key => $value) {
  5. $r[$key] = is_scalar($value) ? $callback($value) : array_map_recursive($callback, $value);
  6. return $r;
  7. }
  8. }
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.