Monday, 15 March 2010

php - divide the multidimensional array -



php - divide the multidimensional array -

i have initial array:

array ( [no] => array ( [<30] => 3 [>30] => 5 [>50] => 2 ) [yes] => array ( [<30] => 4 [>30] => 2 [>50] => 7 ) [maybe] => array ( [<30] => 7 [>30] => 9 [>50] => 10 ) )

whether above array can split multiple array variables yes, no , maybe. such :

$yes = array(3,5,2); $no = array(4,2,7); $maybe = array(7,9,10);

you can seek this.

$result = array(); foreach($data $response) $result[] = array_values($response); list($no, $yes, $maybe) = $result;

where $data array shown in question.

you can access 3 values $no, $yes, , $maybe assuming order of $data respective order.

php arrays

No comments:

Post a Comment