Forum Moderators: coopster

Message Too Old, No Replies

php array

how to print up

         

c0nsur

2:14 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



hey guys!
could you help me with my idea?

i wanna list all search engine here like that:

example:
$searchengines[]=array("Netscape","search");
$searchengines[]=array("explorer","query");

so how could i print up each one and get its value?

thanks for helping :)

saoi_jp

3:01 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



From php on-line manual:

$firstquarter = array(1 => 'January', 'February', 'March');
print_r($firstquarter);

will display : Array
(
[1] => January
[2] => February
[3] => March
)

Or use a foreach(), like this:
foreach($searchengines as $key=>$value)
{
echo "<div>" . $value . "</div>";
}

Slade

3:10 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



Look up print_r if you just want to dump the array.

Look up array's in general at www.php.net and you'll see various examples of loops. My favorite is while/each.

edit: Well, that's what happens when you wait 20 minutes to finish posting...

[edited by: Slade at 3:11 pm (utc) on Aug. 5, 2003]

c0nsur

3:11 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



i just tried your solution with -->

foreach($searchengines as $key=>$value)
{
echo "<div>" . $value . "</div>";
}

but it only prints the last array :s

c0nsur

3:26 pm on Aug 5, 2003 (gmt 0)

10+ Year Member



ok everything is fine

now i works thanks guys! :)