php 多维数组小问题
$families = array
(
"Griffin"=>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire"=>array
(
"Glenn"
),
"Brown"=>array
(
"Cleveland",
"Loretta",
"Junior"
)
);
//正如#1和#2楼所说对于楼主的例子来说第二个写法确实存在问题
//如果你实在想要一个值不妨改一下数组
$families = array
(
"Griffin"=>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire"=>array
(
"Glenn"
),
"Brown"=>array
(
"Cleveland",
"Loretta",
"Junior"
),
"Peter"=>9
);
$Griffin=array(
"Peter",
"Lois",
"Megan"
);
print_r($families['Griffin'][0]);
print_r($Griffin[0]);
print_r($families[$Griffin[0]]);
//将名为fmilies数组的 下标值为[Griffin],[0]取出
$families[Griffin][0],
//将名为fmilies数组的 下标值为[Griffin[0]]取出
$families[Griffin[0]],