ttmt Posted February 10, 2009 Share Posted February 10, 2009 Hi all I have a multidimensional array (one array that contains 2 other arrays). Array ( [0] => Array ( [0] => 26 [1] => 27 [2] => 28 ) [1] => Array ( [0] => .jpg [1] => .jpg [2] => .jpg ) ) I want to split this array into two seperate arrays like so Array ( [0] => 29 [1] => 30 [2] => 31 ) Array ( [0] => .jpg [1] => .jpg [2] => .jpg ) I tried this - $photo_id_ext_arr is the multidiemsional array for($i=0;$i<=count($photo_id_ext_arr);$i++){ array_push($photo_id, $photo_id_ext_arr); array_push($ext, $photo_id_ext_arr); } print_r($photo_id); print_r($ext); but it produces 3 of everything - I can see why it's doing it but I can't see how to produce 1 of each. Array ( [0] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) [1] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) [2] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) ) Array ( [0] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) [1] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) [2] => Array ( [0] => Array ( [0] => 24 [1] => 25 ) [1] => Array ( [0] => .jpg [1] => .jpg ) ) ) Quote Link to comment Share on other sites More sharing options...
anthylon Posted February 10, 2009 Share Posted February 10, 2009 I think this is what you need: <? $my_arr = array (array(26, 27, 28), array ('.jpg', '.jpg', '.jpg')); $first_arr = $my_arr[0]; $second_arr = $my_arr[1]; ?> Maybe I understand wrong your question . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.