tags:

views:

33

answers:

2

i want take the particular column all value in multidimensional array...

i need to get the value of or column ("rose","daisy","orchid")...

how do get?

is there any predefined function? because in my array have 1000 record, so loop will continue to run 1000 times, program will slow, so...

+1  A: 

Iterate through each array in the array, choosing only one key (Sorry if that sounds a bit confusing, here's what I mean):

$flowers = array();
$flowers[] = array('type'=>'rose', 'color'=>'red');
$flowers[] = array('type'=>'daisy', 'color'=>'white');
$flowers[] = array('type'=>'orchid', 'color'=>'pink');

foreach ($flowers as $flower) {
    echo $flower['type'];
}

This will print out whatever's in column 'type' for each flower.

Lotus Notes
is there any predefined function?because in my array have 1000 record, so loop will continue to run 1000 times, program will slow that's why i asked...
zahir hussain
`foreach` is a "predefined" language construct, see http://docs.php.net/foreach
VolkerK
A: 
<?php
$shop = array( array("rose", 1.25 , 15),
               array("daisy", 0.75 , 25),
               array("orchid", 1.15 , 7)
          );

echo $shop[0][0]." costs ".$shop[0][1]." and you get ".$shop[0][2]."\n";
echo $shop[1][0]." costs ".$shop[1][1]." and you get ".$shop[1][2]."\n";
echo $shop[2][0]." costs ".$shop[2][1]." and you get ".$shop[2][2]."\n";

?>
muruga