PHP数组,输出,仅在type ='image / jpeg'时输出 [英] PHP array, output, output only where type = 'image/jpeg'
本文介绍了PHP数组,输出,仅在type ='image / jpeg'时输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有php数组($ _FILE [失败])我只需要输出类型为 image / jpeg或 image / jpg的名称...
I have php array ($_FILE[fails]) I need to output only thous names where type is "image/jpeg" or "image/jpg" ...
array(5) { ["name"]=> array(4) { [0]=> string(16) "3970867_460s.jpg" [1]=> string(12) "DSCI0783.JPG" [2]=> string(8) "dump.php" [3]=> string(0) "" }
["type"]=> array(4) { [0]=> string(10) "image/jpeg" [1]=> string(10) "image/jpeg" [2]=> string(24) "application/octet-stream" [3]=> string(0) "" }
["tmp_name"]=> array(4) { [0]=> string(27) "C:\Windows\Temp\phpC9C9.tmp" [1]=> string(27) "C:\Windows\Temp\phpC9DA.tmp" [2]=> string(27) "C:\Windows\Temp\phpC9DB.tmp" [3]=> string(0) "" }
["error"]=> array(4) { [0]=> int(0) [1]=> int(0) [2]=> int(0) [3]=> int(4) } ["size"]=> array(4) { [0]=> int(101011) [1]=> int(55354) [2]=> int(12290) [3]=> int(0) }
}
该怎么做?
和foreach?
How to do it? with foreach?
foreach ($_FILES["fails"] as $x => $y ) {
echo $y->....something here?
if(($y->... == 'image/jpeg') AND (..)) {}
}
谢谢!
推荐答案
for ($i = 0; $i < count($_FILES['fails']['name']); $i++) {
if ($_FILES['fails']['type'][$i] == "image/jpeg" || $_FILES['fails']['type'][$i] == "image/jpg") {
echo "Name : " . $_FILES['fails']['name'][$i];
echo "Type : " . $_FILES['fails']['type'][$i];
}
}
这将回显每个图像的名称和类型/数组中的jpg或图像/ jpeg。
This will echo the name and type of every image/jpg or image/jpeg in the array.
这篇关于PHP数组,输出,仅在type ='image / jpeg'时输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文