I have the following form that when sending it with multiple images, it generates a multidimensional array with all the data ordered by default.
HTML and PHP form:
<?php
if(array_key_exists('send', $_POST)) {
echo "<pre>"; print_r($_FILES);
}
?>
<html>
<body>
<form enctype="multipart/form-data" action="" method="POST">
<input name="image[]" type="file" multiple />
<input type="submit" name="send" value="Send" />
</form>
</body>
</html>
When I send it, it generates an array of this type:
$file1 = array(
'imagen' => array(
'name' => array(
'Image_name',
'Image_name'
),
'type' => array(
'jpg',
'jpg'
),
'tmp_name' => array(
'jpg',
'jpg'
),
'error' => array(
0,
0
),
'size' => array(
'200',
'200'
)
)
);
I need to sort the data with PHP and preferably foreach cycles of this array more easily and that the values can be together.
Example, something similar to this:
$file2 = array(
array(
'name' => 'Image_name',
'type' => 'jpg',
'tmp_name' => 'jpg',
'error' => 0,
'size' => 200
),
array(
'name' => 'Image_name',
'type' => 'jpg',
'tmp_name' => 'jpg',
'error' => 0,
'size' => 200
)
);
I appreciate your help.