_FILES array
An <input type="file" name="foo"> produces this
<?php
array (
'foo' =>
array (
'name' => '',
'type' => '',
'tmp_name' => '',
'error' => 4,
'size' => 0,
),
)
?>$_FILES array. What do you think foo[bar] will produce?
<?php
array (
'foo' =>
array (
'name' =>
array (
'bar' => '',
),
'type' =>
array (
'bar' => '',
),
'tmp_name' =>
array (
'bar' => '',
),
'error' =>
array (
'bar' => 4,
),
'size' =>
array (
'bar' => 0,
),
),
)
?>
Comments
I don't get it. You mean
I don't get it. You mean dumping $_FILES['foo']['bar'] will print that?
No, <input type="file"
No,
<input type="file" name="foo[bar]">and
<?phpvar_dump($_FILES);
?>
will print that. And it's one of the strangest "design decisions" in PHP.
The "design decision" is to
The "design decision" is to code like this....
$_FILES['foo']['name']['bar'];
But I think that $_FILES['foo']['bar']['name'] would be better...
I don't know where to submit
I don't know where to submit a solution but here you go; What is the output of this and why?
<?phpfor ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i\n";
}
?>
The output is: 2 Your code is
The output is:
2
Your code is equivalent to:
<?phpfor ($i = 0; $i < 5; ++$i) {
if ($i == 2) {
continue print "$i\n";
}
}
?>
From http://ru.php.net/manual/en/control-structures.continue.php:
continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of.
From http://ru.php.net/manual/en/function.print.php:
Print returns 1, always.
That's explains such kind of behavior :)
Post new comment