Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.