note 86187 modified in function.print-r by danbrown
| From: | danbrown@php.net | Date: | Tue, 07 Oct 2008 13:43:54 +0000 |
| Subject: | note 86187 modified in function.print-r by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145124@lists.php.net to get a copy of this message | ||
my take on the highlighted markupped debug function:
<?php
/**
* print_array()
* Does a var_export of the array and returns it between <pre> tags
*
* @param mixed $var any input you can think of
* @return string HTML
*/
function print_array($var)
{
$input =var_export($var,true);
$input = preg_replace("! => \n\W+ array \(!Uims", " => Array ( ",
$input);
$input = preg_replace("!array \(\W+\),!Uims", "Array ( ),", $input);
return("<pre>".str_replace('><?', '>',
highlight_string('<'.'?'.$input, true))."</pre>");
}
?>
--was--
my take on the highlighted markupped debug function:
/**
* print_array()
* Does a var_export of the array and returns it between <pre> tags
*
* @param mixed $var any input you can think of
* @return string HTML
*/
function print_array($var)
{
$input =var_export($var,true);
$input = preg_replace("! => \n\W+ array \(!Uims", " => Array ( ",
$input);
$input = preg_replace("!array \(\W+\),!Uims", "Array ( ),", $input);
return("<pre>".str_replace('><?', '>',
highlight_string('<'.'?'.$input, true))."</pre>");
}
http://php.net/manual/en/function.print-r.php