1// Converts array with multiple values into a single array with all items:
2var merged = [].concat.apply([], arrays);
1new_images = array();
2// format image before upload
3for ($i = 0; $i < count($images['name']); $i++) {
4 $new_images[] = array(
5 'name' => $images['name'][$i],
6 'type' => $images['type'][$i],
7 'tmp_name' => $images['tmp_name'][$i],
8 'error' => $images['error'][$i],
9 'size' => $images['size'][$i],
10 );
11}
12
13<pre>Array
14(
15 [name] => Array (
16 [0] => Screen Shot 2020-10-21 at 10.44.30 AM.png
17 [1] => Screen Shot 2020-10-21 at 9.56.12 AM.png )
18 [type] => Array (
19 [0] => image/png
20 [1] => image/png )
21 [tmp_name] => Array (
22 [0] => /Applications/MAMP/tmp/php/phpnlVcZU
23 [1] => /Applications/MAMP/tmp/php/php1qaHkj )
24 [error] => Array (
25 [0] => 0
26 [1] => 0 )
27 [size] => Array (
28 [0] => 61923
29 [1] => 62194)
30
31)
32</pre>
33
34// to
35<pre>Array
36(
37 [0] => Array (
38 [name] => Screen Shot 2020-10-21 at 10.44.30 AM.png
39 [type] => image/png
40 [tmp_name] => /Applications/MAMP/tmp/php/phpJz6xqI
41 [error] => 0
42 [size] => 61923 )
43 [1] => Array (
44 [name] => Screen Shot 2020-10-21 at 9.56.12 AM.png
45 [type] => image/png
46 [tmp_name] => /Applications/MAMP/tmp/php/phpHSBXaI
47 [error] => 0
48 [size] => 62194 )
49)
50</pre>