Answers to various technical questions on php programming, mysql, linux, and many more categories.
Home / Programming / php / How can I format my php print_r statements to be more readable in html?
How can I format my php print_r statements to be more readable in html?
Last updated: 07/01/2009
Normally print_r spits out an array with out any html linebreaks, so in a web browser, it is hard to see what your array looks like. I just throw in this little function to clean up the output:
function print_r_html ($arr) { ?><pre><? print_r($arr); ?></pre><? }
Just call it with "print_r_html($array);" for quick debugging of your scripts.