我的var_dump
$info
看起来像这样:
array(4) {
[0]=> string(5) "dummy"
[1]=> array(5) { [0]=> string(8) "Karaffen" [1]=> string(16) "Öl auf Leinwand" [2]=> string(11) "83 x 120 cm" [3]=> string(3) " - " [4]=> string(1) "1" }
[2]=> array(5) { [0]=> string(6) "Santé" [1]=> string(16) "Öl auf Leinwand" [2]=> string(11) "80 x 100 cm" [3]=> string(3) " - " [4]=> string(1) "1" }
[3]=> array(5) { [0]=> string(11) "Landleben I" [1]=> string(16) "Öl auf Leinwand" [2]=> string(11) "70 x 100 cm" [3]=> string(3) " - " [4]=> string(1) "1" }
}
我希望通过此访问权限:echo $info[1][0];
但回显始终为NULL
。怎么了?
以下是完整的代码:
$info = array();
$info[0] = "dummy";
$info[1] = array();
$info[1][0] = "Karaffen";
$info[1][1] = "Öl auf Leinwand";
$info[1][2] = "83 x 120 cm";
$info[1][3] = " - ";
$info[1][4] = "1";
$info[2] = array();
$info[2][0] = "Santé";
$info[2][1] = "Öl auf Leinwand";
$info[2][2] = "80 x 100 cm";
$info[2][3] = " - ";
$info[2][4] = "1";
$info[3] = array();
$info[3][0] = "Landleben I";
$info[3][1] = "Öl auf Leinwand";
$info[3][2] = "70 x 100 cm";
$info[3][3] = " - ";
$info[3][4] = "1";
$numFiles = count($info);
echo $numFiles." sind da<br>\r\n";
var_dump($info[1]);
$t = "<br>\r\n"; $i = 0;
echo $t."here: ";
echo $info[1][2];
echo " END";
答案 0 :(得分:0)
它应该工作。我使用答案来格式化代码,这不在评论中:
$info = array(
"dummy",
array("Karaffen", "Öl auf Leinwand", "83 x 120 cm", " - ", "1"),
array("Santé", "Öl auf Leinwand", "80 x 100 cm", " - ", "1"),
array("Landleben I", "Öl auf Leinwand", "70 x 100 cm", " - ", "1")
);
var_dump($info[1][0]);
echo ($info[1][0]);
输出:
string 'Karaffen' (length=8)
Karaffen
答案 1 :(得分:0)
代码没有错误,所以这应该有效:
$info = array("dummy",
array("Karaffen", "Öl auf Leinwand", "83 x 120 cm", " - ", "1"),
array("Santé", "Öl auf Leinwand", "80 x 100 cm", " - ", "1"),
array("Landleben I", "Öl auf Leinwand", "70 x 100 cm", " - ", "1")
);
echo $info[1][0];
输出:
Karaffen