<?php $people=array('sally','george','peter'); //$people[0]='sally'; //$people[1]='george'; //$people[2]='peter'; print_r($people); echo '</br>'; echo $people[0]; echo '</br>'; $people1=array('name'=>'sally','position'=>'president','DOB'=>'1970'); //$people1['name']='sally'; //$people1['position']='president'; //$people1['DOB']='1970'; print_r($people1); echo '</br>'; echo $people1['name']; echo '</br>'; $people2=array( array('name'=>'sally','position'=>'president','DOB'=>'1970'), array('name'=>'george','position'=>'clerk','DOB'=>'1990'), array('name'=>'peter','position'=>'administrator','DOB'=>'1972'), ); print_r($people2); echo '</br>'; echo $people2[0]['name']; echo '</br>'; ?>
以上代码运行结果如下: