Debug/Show Array





4
Date Submitted Fri. Jul. 20th, 2007 7:34 PM
Revision 1 of 1
Scripter ColdKeyboard
Tags Array | debug | Show
Comments 0 comments
Very useful function that you can use to debug/show your array and it's contents.

Sometimes when you have problems with arrays and print_r() isn't very nice way to show array values because it shows everything in one line and then it is very hard to debug... this way I think it's much much easier.

<html>
<head>
</head>

<body>
<?php
        function show_array ($array) {
                if(!empty($array)) {
                foreach($array as $item) {
                        print "<pre>";
                        print_r($array);
                        print "</pre>";
                }
                }
        }
       
        // Usage
        // Let's say that you have some multy dimension array named $array and you want to
        // see what's inside that array you can use something like this
        show_array($array);

?>
</body>
</html>
 

Sasa Karanovic

Sasa Karanovic
www.MrdniSe.com
www.SasaKaranovic.com

Comments

There are currently no comments for this snippet.

Voting

Votes Down