Quick Search for:  in language:    
function,recursively,displays,contents,single
   Code/Articles  |  Newest/Best  |  Community  |  Jobs  |  Other  |  Goto  | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 107,779. lines
 Jobs: 40. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for PHP.
Click here to see a screenshot of this code!Debug Window
By Hohl David on 12/30

(Screen Shot)

Click here to see a screenshot of this code!Add Google search technology to your site without Google branding.
By Sean Cannon on 12/29

(Screen Shot)

PHP System Function
By Ruben Benjamin on 12/29


Click here to see a screenshot of this code!MySQL GuestBook 1.0
By Uis on 12/27

(Screen Shot)

Click here to see a screenshot of this code!MySQL Guestbook
By Uis on 12/27

(Screen Shot)

Click here to see a screenshot of this code!MySQL Guestbook
By Uis on 12/27

(Screen Shot)

Click here to see a screenshot of this code!PHP Chat
By Kevin Harris on 12/25

(Screen Shot)

Preload whole directory of images
By Roland Osbeck on 12/23


Sessions
By Michael 'plasma' McMullen on 12/23


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Display array contents

Print
Email
 
VB icon
Submitted on: 11/30/2003 11:59:25 PM
By: Peter Kionga-Kamau  
Level: Advanced
User Rating: By 1 Users
Compatibility:PHP 4.0

Users have accessed this code 578 times.
 
 
     This function recursively displays the contents of any single, multi- or mixed-dimensional array in tab-indented format, where you may specify the tab character/string to use along with the overall indentation, with defaults used if specification is missing.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    //**************************************
    //     
    // for :Display array contents
    //**************************************
    //     
    Free for unrestricted use, except sale - do not resell.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Display array contents
    // Description:This function recursively
    //     displays the contents of any single, mul
    //     ti- or mixed-dimensional array in tab-in
    //     dented format, where you may specify the
    //     tab character/string to use along with t
    //     he overall indentation, with defaults us
    //     ed if specification is missing.
    // By: Peter Kionga-Kamau
    //
    // Inputs:single/multi-dimensional array
    //     - the array you want to view
    (optional) string $tab | default = "    " - your custom indentation string
    (optional) int $indent | default = 0 - overall indentation
    //
    // Returns:html-formatted string (includ
    //     es <BR> tags)
    //
    // Assumes:This function is intended for
    //     debugging purposes. remember, you must u
    //     se "echo LIST_CONTENTS($array);" and not
    //     simply "LIST_CONTENTS($array);". This is
    //     a design feature - so that you can inspe
    //     ct arrays in one place and echo them lat
    //     er if required.
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/vb/scripts/Sh
    //     owCode.asp?txtCodeId=1184&lngWId;=8    //for details.    //**************************************
    //     
    
    function LIST_CONTENTS($arrayname,$tab="    ",$indent=0) 
    {// recursively displays contents of the array and sub-arrays: 
    // This function (c) Peter Kionga-Kamau 
    //     (http://www.pmkmedia.com) 
    // Free for unrestricted use, except sal
    //     e - do not resell. 
    // use: echo LIST_CONTENTS(array $arrayn
    //     ame[, string $tab, int $indent]); 
    // $tab = string to use as a tab, $inden
    //     t = number of tabs to indent result 
    while(list($key, $value) = each($arrayname)) 
    { 
    for($i=0; $i<$indent; $i++) $currenttab .= $tab; 
    if (is_array($value)) 
    { 
    $retval .= "$currenttab$key : Array: <BR>$currenttab{<BR>"; 
    $retval .= LIST_CONTENTS($value,$tab,$indent+1)."$currenttab}<BR>"; 
    } 
    else $retval .= "$currenttab$key => $value<BR>"; 
    $currenttab = NULL; 
    } 
    return $retval; 
    }

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
12/25/2003 1:07:33 PM:Timmus
Why not just use Print_R?  
http://www.php.net/manual/en/function.pr
int-r.php
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/26/2003 9:36:54 PM:Peter Kionga-Kamau
If you are not aware of the existence 
of print_r(), you can use this function.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.