note 16157 modified in function.print-r by aidan
| From: | aidan@php.net | Date: | Mon, 11 Oct 2004 13:05:33 +0000 |
| Subject: | note 16157 modified in function.print-r by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78329@lists.php.net to get a copy of this message | ||
To quote HTML special chars in an array before print_r(), use the following:
<?php
array_walk(&$array, 'quote');
print_r($array);
function quote(&$val) {
if (is_array($val)) {
array_walk(&$val, 'quote');
return;
}
$val = htmlentities($val);
}
?>
--was--
To quote HTML special chars in an array before print_r(), use the following (an extra flag for
print_r() would be useful!):
array_walk(&$array, 'quote');
print_r($array);
function quote(&$val) {
if (is_array($val)) {
array_walk(&$val, 'quote');
return;
}
$val = htmlentities($val);
}
http://php.net/manual/en/function.print-r.php