我的$info
var_dump
看起來是這樣的:訪問多維數組在PHP
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";
你從'$ info [1]'得到的迴應是什麼? – klauskpm 2014-11-06 12:14:30
你的'$ info [1]'只有5個鍵,所以沒有'$ info [1] [10]'。你想訪問哪個元素?我想你想''info [1] [4]' – vaso123 2014-11-06 12:15:00
@lolka_bolka他說'$ info [1] [0]',而不是'$ info [1] [10]'。 – klauskpm 2014-11-06 12:15:48