note 117746 added to function.print-r

From: Date: Fri, 31 Jul 2015 17:43:11 +0000
Subject: note 117746 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-203237@lists.php.net to get a copy of this message
Another attempt that tries to overcome the memory blowout when the passed in data has mutual recursion. <?php function safe_print_r($data, $nesting = 5, $indent = '') { if (! is_object($data) && ! is_array($data)) { var_dump($data); } elseif ($nesting < 0) { echo "** MORE **\n"; } else { echo ucfirst(gettype($data)) . " (\n"; foreach ((array) $data as $k => $v) { echo $indent . "\t[$k] => "; safe_print_r($v, $nesting - 1, "$indent\t"); } echo "$indent)\n"; } } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 95.253.99.177 ---- Manual Page -- http://php.net/manual/en/function.print-r.php Edit -- https://master.php.net/note/edit/117746 Del: integrated -- https://master.php.net/note/delete/117746/integrated Del: useless -- https://master.php.net/note/delete/117746/useless Del: bad code -- https://master.php.net/note/delete/117746/bad+code Del: spam -- https://master.php.net/note/delete/117746/spam Del: non-english -- https://master.php.net/note/delete/117746/non-english Del: in docs -- https://master.php.net/note/delete/117746/in+docs Del: other reasons-- https://master.php.net/note/delete/117746 Reject -- https://master.php.net/note/reject/117746 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203237) next »