Dorky Posted October 30, 2009 Share Posted October 30, 2009 i cannot find how to break down an array from multiple image post into a usable array to use in a foreach loop? results from a print_r of the $_POST['new_image'] Array ( [name] => Array ( [0] => d.png [1] => sky.jpg ) [type] => Array ( [0] => image/png [1] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) [error] => Array ( [0] => 0 [1] => 0 ) => Array ( [0] => 1028 [1] => 110116 ) ) Array ( [0] => d.png [1] => sky.jpg ) Array ( [0] => image/png [1] => image/jpeg ) Array ( [0] => /tmp/php6WChM0 [1] => /tmp/phpU1UV9g ) Array ( [0] => 0 [1] => 0 ) Array ( [0] => 1028 [1] => 110116 ) Quote Link to comment https://forums.phpfreaks.com/topic/179617-array-image-post/ Share on other sites More sharing options...
Dorky Posted October 30, 2009 Author Share Posted October 30, 2009 i have been all over the web trying to figure this out. please help! Quote Link to comment https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947836 Share on other sites More sharing options...
mikesta707 Posted October 30, 2009 Share Posted October 30, 2009 you could just use a for loop. im assuming you want to do some image upload kind of thing for ($i = 0; $i < count($_POST['new_image']['name']); $i++){ //access each individual element like so $name = $_POST['new_image']['name'][$i]; $size = $_POST['new_image']['size'][$i]; //do rest of stuff } Quote Link to comment https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947862 Share on other sites More sharing options...
Dorky Posted October 30, 2009 Author Share Posted October 30, 2009 you could just use a for loop. im assuming you want to do some image upload kind of thing for ($i = 0; $i < count($_POST['new_image']['name']); $i++){ //access each individual element like so $name = $_POST['new_image']['name'][$i]; $size = $_POST['new_image']['size'][$i]; //do rest of stuff } DUDE YOU ARE THE MAN!!!!! for ($i = 0; $i < count($_FILES['new_image']); $i++){ $imagename = $_FILES['new_image']['name'][$i]; $tmp_name = $_FILES['new_image']['tmp_name'][$i]; how long did that take you. i missed an entire nights sleep for that. Quote Link to comment https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947886 Share on other sites More sharing options...
mikesta707 Posted October 30, 2009 Share Posted October 30, 2009 Haha, yeah the way that HTML arrays are formatted in the PHP Post array are kind of strange, so the first time I encountered this it took some getting used to. Quote Link to comment https://forums.phpfreaks.com/topic/179617-array-image-post/#findComment-947898 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.