Posted By

tasmanweb on 04/28/11


Tagged

php print function echo


Versions (?)

printr: print_r replacement that can handle nested arrays and strings


 / Published in: PHP
 

A print_r replacement function that can handle nested arrays and strings. Usage: printr($array);

  1. /*
  2. A print_r replacement function that can handle nested arrays and strings
  3. Usage: printr($array);
  4. */
  5. function printr($array){
  6. echo '<blockquote>';
  7. if (!is_array($array)) return;
  8. foreach($array as $key => $value){
  9. if (is_array($value)){ printr($value);}else{echo htmlspecialchars($value).'<br />';}
  10. }
  11. echo '</blockquote>';
  12. }

Report this snippet  

You need to login to post a comment.