Page 1 of 1

Echo the values of an array?

Posted: Tue Feb 24, 2009 8:56 am
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

Re: Echo the values of an array?

Posted: Tue Feb 24, 2009 8:57 am
by VladSun
implode() ?

Re: Echo the values of an array?

Posted: Tue Feb 24, 2009 9:03 am
by Sindarin
Thanks, it worked.

Re: Echo the values of an array?

Posted: Tue Feb 24, 2009 10:05 am
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.