user4492612
user4492612

Reputation:

Parse an array in PHP

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.

Upvotes: 2

Views: 61

Answers (1)

Code Lღver
Code Lღver

Reputation: 15603

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";
    }
}

Upvotes: 1

Related Questions