For the incorrect usage of explode()
The following line contains your explode()
call
$src = explode("+",$src);
At this stage (using the code example you've posted above) $src will not contain any data to be explode()
ed. You want to use the $_GET['files']
value as the parameter
$src = explode("+", $_GET['files']);
See the php docs on explode for more info on how it works.
For your looping/iteration
For your loop you may also want to change your loop to check for $i < count($src)
. If you have file1+file2+file3+file4
the array will have 4 items at index 0, 1, 2 and 3. You want that statement to read $i < 4
not $i <= 4
.
However... as @TML suggested, using foreach is preferred over for when directly iterating over an array.
foreach(explode('+', $_GET['files']) as $file)
{
// work with $file here (each one will be an element of the exploded array)
}
For the sake of simplifying the example, the above is essentially equivalent to
$src = explode('+', $_GET['files']);
foreach($src as $file)
{
// work with $file here (each one will be an element of the exploded array)
}