Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // PHP - Print array or object in readable form
- // replaces var_dump or print_r
- if ( !function_exists( 'pretty_print' ) ) {
- function pretty_print ( $item, $key = '', $indent = 0 ) {
- $pad = str_repeat( ' ', $indent );
- $type = gettype ($item );
- print $pad.$type;
- switch ($type) {
- case 'array':
- case 'object':
- print ' '.$key.'<br>'.PHP_EOL;
- $indent = $indent + 4;
- foreach ($item as $key => $property) {
- pretty_print( $property, $key, $indent );
- }
- break;
- default:
- print ' '.$key.' '.$item.'<br>';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement