My code has made a pass through the $_FILES array and unset a number of files. The array now has keys that don't start with zero and are also out of sequence.
[userfile] => Array
(
[name] => Array
(
[2] => IMG_20170325_124043610_HDR.jpg
[3] => video_icon.png
[5] => watersports.gif
[7] => IMG_20170325_153726906_HDR.jpg
)
I would like to rename the keys sequentially starting from zero, like this:
[userfile] => Array
(
[name] => Array
(
[0] => IMG_20170325_124043610_HDR.jpg
[1] => video_icon.png
[2] => watersports.gif
[3] => IMG_20170325_153726906_HDR.jpg
)
I don't want to change the key values for [ userfile] [name] or any of the other non-numeric keys. Is there a function for this? I would like to do something along these lines:
// FILE COUNT IS PROVIDED BY CODE ABOVE
// Is $num equal to $fileCount?
$num = 0;
// Change the value of the key through iteration
while ($num < $fileCount) {
// need a built in function that allows the key change
**reset_key**($_FILES['userfile']['name'][$num]);
**reset_key**($_FILES['userfile']['type'][$num]);
**reset_key**($_FILES['userfile']['tmp_name'][$num]);
**reset_key**($_FILES['userfile']['error'][$num]);
**reset_key**($_FILES['userfile']['size'][$num]);
}
$num++;
Is this even the correct approach, or should I be trying something else here? Thanks so much for your input!
Cheers,
shackleton