2

How can I parse an array like this:

Array
(
    [file-0] => Array
        (
            [name] => 3676256.zip
            [type] => application/zip
            [tmp_name] => /tmp/phpKx0Os0
            [error] => 0
            [size] => 18426173
        )

)

I already try without success:

foreach ($_FILES as $key => $item) {
    echo "$item\n";
}

Thanks.

2
  • foreach ($_FILES['file-0'] as $key => $item) { Commented Feb 6, 2015 at 16:08
  • var_dump($item) would show you what you need to do... Commented Feb 6, 2015 at 16:11

1 Answer 1

1

Try this:

foreach ($_FILES as $key => $item) {
    echo $item['name']."\n";
    echo $item['type']."\n";
    echo $item['tmp_name']."\n";
}

You have associative array and $item is an array.

OR

you can do this:

foreach ($_FILES as $key => $item) {
    foreach ($item as $inx => $val) {
        echo $val."\n";
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.