note 47178 modified in function.array-walk by thiago

From: Date: Tue, 22 Jul 2008 16:59:04 +0000
Subject: note 47178 modified in function.array-walk by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142509@lists.php.net to get a copy of this message
If array_walk_recursive() is not present and you want to apply htmlentities() on each array element you can use this: <?php function array_htmlentities(&$elem) { if (!is_array($elem)) { $elem=htmlentities($elem); } else { foreach ($elem as $key=>$value) $elem[$key]=array_htmlentities($value); } return $elem; } // array_htmlentities() ?> If you want to output an array with print_r() and you have html in it this function is very helpful. --was-- If array_walk_recursive() is not present and you want to apply htmlentities() on each array element you can use this: function array_htmlentities(&$elem) { if (!is_array($elem)) { $elem=htmlentities($elem); } else { foreach ($elem as $key=>$value) $elem[$key]=array_htmlentities($value); } return $elem; } // array_htmlentities() If you want to output an array with print_r() and you have html in it this function is very helpful. http://php.net/manual/en/function.array-walk.php

« previous php.notes (#142509) next »