Log in

View Full Version : Display the 2nd value of each array in a multidimensional array



toe_head2001
04-20-2009, 07:47 PM
I have this multidimensional array. How can I display all the value of, for example, [1]? So I would get 671, 1, and Standard.


Array
(
[id] => Array
(
[0] => 546
[1] => 671
[2] => 983
)
[quant] => Array
(
[0] => 5
[1] => 1
[2] => 7
)
[notes] => Array
(
[0] => Heck Yes
[1] => Standard
[2] => None
)
)

Thanks

techietim
04-20-2009, 07:48 PM
foreach($arr as $item){
echo $item[1];
}

ganu
04-21-2009, 06:10 AM
<?php
$People[0][1] = 546;
$People[0][2] = 671;
$People[0][3] = 983;
$People[1][1] = 5;
$People[1][2] = 1;
$People[1][3] = 7;
$People[2][1] ="Heck Yes";
$People[2][2] = "Standard";
$People[2][3] = "None";
//echo sizeof($People);
for($i = 0; $i < sizeof($People); $i++)
{
for($j = 0; $j < 1; $j++)
print $People[$i][2] . "<br>";
}

?>