value//创建数组$userName = array('lily','milly','amy');print_r($userName);echo '';$userName1 = array('li'=>'lily','milly','amy');print_r($userName1);echo '';$userName2 = array('sister'=>'lily','brother'=>'milly','friend'=>'amy');print_r($userName2);echo '';//访问数组echo $userName2['sister'];echo '';//追加元素$userAge = array('lily'=>12);print_r($userAge);echo '';$userAge['mac']=23;$userAge['pity']=33;print_r($userAge);echo '';//直接创建数组,不通过array$userFrom['lily'] = 'wuhan';$userFrom['mac'] = 'haungshi';$userFrom['pit'] = 'shanghai';print_r($userFrom);echo '';if(is_array($userFrom)){ echo 'userFrom is array';}else{ echo 'userFrom is not array';}echo '';//问题:不能通过for循环访问元素//只能通过foreach()遍历数组元素foreach($userFrom as $value){ echo $value; echo '';}foreach($userFrom as $key => $value){ echo $key.'---comes from---'.$value; echo '';}?>