printr: print_r replacement that can handle nested arrays and strings


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

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


Copy this code and paste it in your HTML
  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. echo htmlspecialchars("$key: ");
  10. if (is_array($value)){ printr($value);}else{echo htmlspecialchars($value).'<br />';}
  11. }
  12. echo '</blockquote>';
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.