Subscribe to How-To Geek

Printing the contents of a PHP Array

This is a pretty common task, but it’s surprising how many PHP newbies don’t know about it yet. If you want to see the structure of your PHP Array, all you need to do is this:

 

print_r($myarray);

This will give you a listing of all the items in the array, including multi-dimensional arrays. Obviously this should only be used for testing / debugging purposes.

| More
This article was originally written on 09/26/06 Tagged with: PHP, Programming

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:

Comments (7)

  1. sven

    and if you like it human-readable:
    echo “”; print_r($myarray); echo “”;

    have fun!

  2. Magic.Crazy

    this is more human-readable :

    echo ”;
    print_r($array);
    echo ”;

  3. Hmmmm

    You may want to try this:

    echo “”;
    print_r($location);
    echo “”;

  4. Hmmmm

    echo “(html open tag)pre(html close tag)”;
    print_r($location);
    echo “\”;

  5. Hmmmm

    echo “(less than sign)pre(greater than sign)”;
    print_r($location);
    echo “(less than sign)/pre(greather than sign)”;

  6. Hmmmm

    between the quotes are the html pre tags (open and then close).

  7. jeroen

    surprising how very helpful this post is for php newbies like me :)
    thx alot!


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Our Friends
Getting Started


About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
conhost.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.