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