note 86187 modified in function.print-r by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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 &lt;pre&gt; 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('>&lt;?', '>', highlight_string('<'.'?'.$input, true))."</pre>");
}

http://php.net/manual/en/function.print-r.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.