Jump to content

Create a while loop from an array


nzol

Recommended Posts

HI all,

 

I need help to get data out of an array using a while loop or something simalar.

 

What I have, is this:

 

<?php

$data = array(

  1  => array(
                         "name" => "Jordan Smith",
		 "age"    => "16 Years 0 Months"
	),
  2  => array(
                        "name" => "Olivia Smith",
                "age"    => "13 Years 12 Months"
	)
);

 

Now, what I did, is I constructed this:

while($result=$data[1]) {
echo $result['name'];
} 

But it echoed "Jordan Smith" for infinity down the page.

 

If anyone can help be do this, it will be great. Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/235583-create-a-while-loop-from-an-array/
Share on other sites

Archived

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

×
×
  • Create New...

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.