Print Array for Debugging


/ Published in: PHP
Save to your folder(s)

It's easy to print out an array that is readable and with only one line of code. This can easily be turned into a nifty function.


Copy this code and paste it in your HTML
  1. // The One liner
  2. // The <pre> tags make it looks nice and neat and readable.
  3. <pre><? print_r($array); ?></pre>
  4.  
  5.  
  6. // The function
  7. function pretty_print($array) {
  8. echo "<pre>";
  9. print_r($array);
  10. echo "</pre>";
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.