我是一个php初学者,我有一个变量,什么存储关于上传图像的信息
得到一个多维数组
Array
(
[0] => Array
(
[errors] => Array
(
)
[path] => addons/uploads/albums/1/1/rDtKgyVAvTjSkLA.jpg
[filename] => rDtKgyVAvTjSkLA.jpg
[original_name] => rachaelCache_5750270_thm.jpg
[resizes] => Array
(
[0] => 1
[1] => 1
)
)
[1] => Array
(
[errors] => Array
(
)
[path] => addons/uploads/albums/1/1/qTLglBgAPxvDFtr.png
[filename] => qTLglBgAPxvDFtr.png
[original_name] => Screen Shot 2013-03-02 at 11.28.48 AM.png
[resizes] => Array
(
[0] => 1
[1] => 1
)
)
)
但是当我查询它时,我只得到一个结果
foreach ($upload as $row) {
echo $row['filename'];
}
谁能告诉我为什么会这样? 重新创建您的代码作为实时演示,工作正常:--> http://3v4l.org/986e7
$upload = array(array(
'errors' => array(),
'filename' => '/some/path/to/a/file.jpg'),
array(
'errors' => array(),
'filename' => '/yet/another/path.jpg'));
var_dump($upload);
foreach ($upload as $x)
echo $x['filename'],"<br>";
echo $upload[0]['filename'];
找出什么是错的,我把一个var_dump($upload);
在你的foreach
-循环之前,看看$upload是否持有你认为它持有。