Echo the values of an array?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Echo the values of an array?

Post by Sindarin »

I found print_r but it prints the contents of my array in a non-readable format.
All the documents I've googled talk about print_r
How can I display something like,

the array:
$file_extensions = array("'.jpg','.gif','.png'");

the output:
Extensions allowed: .jpg, .gif, .png
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Echo the values of an array?

Post by VladSun »

implode() ?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Echo the values of an array?

Post by Sindarin »

Thanks, it worked.
semlar
Forum Commoner
Posts: 61
Joined: Fri Feb 20, 2009 10:45 pm

Re: Echo the values of an array?

Post by semlar »

You can echo "<pre>" tags around your print_r or view the source of the document (or output it as plain text) to see it formatted correctly. It uses whitespace to format the array, which html basically ignores. Of course print_r is mostly for debugging things.
Post Reply