Nice print_r() for the web
July 18th, 2007Here’s a nicer version of the print_r() function that displays much better on web pages.
function dump($in) {
ob_start();
$out= "<pre>";
print_r($in);
$out.= ob_get_contents();
ob_end_clean();
$out.= "</pre>";
return $out;
}
Usage:
echo $out;
It should print something that is actually readable, as opposed to the built in print_r() function that provides no line breaks in a browser.
| Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo |
Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the PHP category.