Jump to content

Archived

This topic is now archived and is closed to further replies.

willpower

Array

Recommended Posts

if I have an array $result

how do I echo all the contents?

$result[1], $result[2]..etc

Share this post


Link to post
Share on other sites
print_r($array) works great for me

or...

You could also do

foreach($array as $value)
{
echo "$value, ";
}

Share this post


Link to post
Share on other sites
[!--quoteo(post=350959:date=Mar 2 2006, 09:27 AM:name=marker5a)--][div class=\'quotetop\']QUOTE(marker5a @ Mar 2 2006, 09:27 AM) [snapback]350959[/snapback][/div][div class=\'quotemain\'][!--quotec--]
print_r($array) works great for me
[/quote]

yep, and it's really helpful to put it within <pre> tags, too:

[code]
echo "<pre>\n";
print_r($array);
echo "</pre>\n";
[/code]

Share this post


Link to post
Share on other sites
You can do the last suggestion in one line:
[code]<?php echo '<pre>'.print_t($array,true).'</pre>'; ?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.