怎麼能指望我這個數組低於總項目?計數多維數組中總項目
Array
(
[upload] => Array
(
[name] => Array
(
[0] => 1024x768.jpg
[1] => 1280x800.jpg
[2] => 1280x1024.jpg
[3] => 1440x900.jpg
)
[type] => Array
(
[0] => image/jpeg
[1] => image/jpeg
[2] => image/jpeg
[3] => image/jpeg
)
[tmp_name] => Array
(
[0] => C:\wamp\tmp\php34FE.tmp
[1] => C:\wamp\tmp\php353D.tmp
[2] => C:\wamp\tmp\php356D.tmp
[3] => C:\wamp\tmp\php35AC.tmp
)
[error] => Array
(
[0] => 0
[1] => 0
[2] => 0
[3] => 0
)
[size] => Array
(
[0] => 469159
[1] => 602230
[2] => 739779
[3] => 707039
)
)
)
這是我的方法,但我認爲它很愚蠢!任何更好的方法/方法來計算數組內的總項目?
<pre>
<?php if ($_FILES) {print_r($_FILES);}?>
</pre>
<?php
echo count($_FILES['upload']['name']);
if(empty($_FILES['upload']['name'][0]))
{
echo '0 file has been uploaded.';
}
?>
千恩萬謝, 劉
關於什麼的愚蠢 '計數();' ? – 2010-07-23 22:50:22
我不明白這裏有什麼問題。這正是計算元素的正確方法。 – Jhong 2010-07-24 00:47:38
大聲笑可能我讓它太複雜了!只是它可能有另一種更好的辦法... :-) – laukok 2010-07-24 01:45:49