SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    printing multidemensional arrays?

    what is the best way to print out the values of a multidemensional array?
    print_r is all just one long line and its very confusion

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a function I made a while back to do it:
    PHP Code:
    function displayIt($myArray){
        
    ksort($myArray);
        foreach(
    $myArray as $key=>$val){
            echo 
    "<b>$key</b>";
            if (!
    is_array($val))
                echo 
    "[$val]";
            echo 
    "<br />\n";
            if (
    is_array($val) && $key != "GLOBALS"){
                echo 
    "<blockquote>\n";
                
    displayIt($val);
                echo 
    "</blockquote>\n";
                }
            }


  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks man, works great


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •