Cradenburg Posted June 7, 2007 Share Posted June 7, 2007 trying to get out of an array dynamically.. ahm $transport = array('foot', 'bike', 'car', array('test1', 'test2')); i'm in test2( $transport[3][1] ), how do I go into $transport[3]? Is there a function capable of doing this? Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/ Share on other sites More sharing options...
taith Posted June 7, 2007 Share Posted June 7, 2007 i have a way of flattening arrays at home... just pm me... i'll get it to you when i can :-) Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/#findComment-270026 Share on other sites More sharing options...
chigley Posted June 7, 2007 Share Posted June 7, 2007 Taith's function: <?php function array_flatten($array){ $out=array(); foreach($array as $k=>$v){ if(is_array($array[$k])){ $out=array_merge($out,array_flatten($array[$k])); }else{ $out[]=$v; } } return $out; } ?> Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/#findComment-270207 Share on other sites More sharing options...
taith Posted June 7, 2007 Share Posted June 7, 2007 YAY! you founded it! Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/#findComment-270208 Share on other sites More sharing options...
Cradenburg Posted June 8, 2007 Author Share Posted June 8, 2007 Thnx. Though I din really have flattening an array in mind. Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/#findComment-270625 Share on other sites More sharing options...
taith Posted June 9, 2007 Share Posted June 9, 2007 well... it turns... $transport = array('foot', 'bike', 'car', array('test1', 'test2')); $transport=array_flatten($transport); print_r($transport); #array('foot','bike','car','test1','test2') which is what you wanted...? Link to comment https://forums.phpfreaks.com/topic/54606-solved-how-do-i-jump-out-of-a-multidimensional-array/#findComment-271316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.