php - array random multidimensional -


hi array want single dimensional array result shown below please

 array ( [maruti suzuki] => array     (         [0] => swift         [1] => ritz         [2] => omni         [3] => new swift dzire         [4] => ertiga         [5] => eeco     )  [chevrolet] => array     (         [0] => cruze     )  ) 

this array want result of array this

array(        [maruti suzuki] => swift        [maruti suzuki] => ritz        [maruti suzuki] => omini        [maruti suzuki] => eeco        [chevrolet] => cruze       ) 

edit build own new array [by hand]

  $result[] = $your_array['maruti suzuki'][0];   $result[] = $your_array['maruti suzuki'][1];   $result[] = $your_array['maruti suzuki'][2];   $result[] = $your_array['maruti suzuki'][5];   $result[] = $your_array['chevrolet'][0]; 

to random array use

 <?php    $res  = call_user_func_array('array_merge', $your_array);    $new = array_rand($res);    $result = array();    foreach($new $key) $result[] = $res[$key]; 

to random array , limit 5 use

 <?php    $res  = call_user_func_array('array_merge', $your_array);    $new = array_rand($res,5);    $result = array();    foreach($new $key) $result[] = $res[$key]; 

in $result random new array in case new keys!


Comments