PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
rubberjohn
Forum Contributor
Posts: 193 Joined: Fri Feb 25, 2005 4:03 am
Post
by rubberjohn » Wed Mar 30, 2005 8:12 am
how do you return the values of an array without using a for loop and without getting the following output:
Code: Select all
Array
(
ї0] => XL
ї1] => gold
)
sorry if this is basic but ive been working for ages now and my brain has stopped working
cheers
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Mar 30, 2005 8:26 am
Code: Select all
echo $array_name[0];
echo $array_name[1];
rubberjohn
Forum Contributor
Posts: 193 Joined: Fri Feb 25, 2005 4:03 am
Post
by rubberjohn » Wed Mar 30, 2005 10:12 am
sorry i should have said that the size of the array is unknown
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Mar 30, 2005 10:17 am
gskaruz
Forum Newbie
Posts: 8 Joined: Mon Mar 15, 2004 6:45 am
Post
by gskaruz » Thu Mar 31, 2005 4:14 am
Code: Select all
for(reset($_POST); $key = key($_POST); next($_POST))
{
echo $key." - ". $_POST[$key]."<BR>";
}
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Thu Mar 31, 2005 4:40 am
Code: Select all
while (list($key,$value) = each($array_name))
{
echo $value;
}