Get data from array

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

Post Reply
blixit
Forum Newbie
Posts: 2
Joined: Fri Feb 01, 2008 12:51 am

Get data from array

Post by blixit »

I want get data from this array:

Code: Select all

array(1) { 
["Part"]=>  array(6) { 
[0]=>  array(5) { 
["Id"]=>  string(2) "51" 
["Description"]=>  string(19) "Description of part" 
["Code"]=>  int(0) 
["Price"]=>  float(15.23) 
["NewValue"]=>  float(5.43) } 
[1]=>  array(5) { 
["Id"]=>  string(11) "57" 
["Description"]=>  string(21) "Description of part 2" 
["Code"]=>  int(0) 
["Price"]=>  float(32.43) 
["NewValue"]=>  float(12.27) } 
[2]=>  array(5) { 
["Id"]=>  string(11) "40" 
["Description"]=>  string(22) "Description of part 3" 
["Code"]=>  int(0) 
["Price"]=>  float(23.87) 
["NewValue"]=>  float(32.87) } 
[3]=>  array(5) { 
["Id"]=>  string(11) "78" 
["Description"]=>  string(13) "Description of part 4" 
["Code"]=>  int(0) 
["Price"]=>  float(43.45) 
["NewValue"]=>  float(23.34) } 
[4]=>  array(5) { 
["Id"]=>  string(11) "16" 
["Description"]=>  string(19) "Description of part 5" 
["Code"]=>  int(0) 
["Price"]=>  float(43.65) 
["NewValue"]=>  float(32.76) } 
[5]=>  array(5) { 
["Id"]=>  string(11) "43" 
["Description"]=>  string(5) "Description of part 6" 
["Code"]=>  int(0) 
["Price"]=>  float(3.43) 
["NewValue"]=>  float(5.54) } 
} }
How can i do that? I use foreach ($result as $id=>$value) but it don't work because $id is "Part"... :(

Thanks in advance
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: Get data from array

Post by JAM »

Check for example is_array(). You can check if the value you want to list in yet another array, and foreach() on that aswell.
blixit
Forum Newbie
Posts: 2
Joined: Fri Feb 01, 2008 12:51 am

Re: Get data from array

Post by blixit »

When is check tjis array with is_array(); it return to me "1".
Post Reply