//参数默认值// function abc($a,$b,$c=0){// echo $a,$b,$c;// }// abc(1,3); //可变参数//function def(){// $arr=func_get_args();// var_dump($arr);//}//echo "<pre>";//def(1,2,3,4,5,6);//echo "</pre>"; //数组定义//$arr1= [];//$arr2= array();//1索引数组//$arr1=[1,2,3,"abc",1,2,3];//2关联数组//$arr2=[// "one" => 1,// "two" => 2,// "three"=> 3//];//echo $arr2["one"];//数组方法//array_push($arr2,"zxc");//array_pop($arr2);//count($arr2);//判断数组中是否存在某个值//in_array("1",$arr2);//数组合并//$arr3 = array_merge($arr1,$arr2); //数组反转//$arr4 = array_reverse($arr2);//数组去重//$arr5 = array_unique($arr1);//删除数组中的元素//unset($arr1[0]);////echo "<pre>";//var_dump($arr2);//echo count($arr2);//var_dump(in_array("1111",$arr2));//var_dump($arr5);//var_dump($arr1);//echo "</pre>"; //数组遍历$arr1 = [1,2,3,4,5,6,7];$arr2=[ "one" => 1, "two" => 2, "three"=> 3, "four" => 4];//for ($i=0;$i<count($arr1);$i++){// var_dump($arr1[$i]);//}//foreach 遍历//foreach ($arr2 as $v){// var_dump($v);//} //foreach ($arr2 as $k=>$v){// echo $k;// echo "----";// echo $v;// echo "<br>";//} //指针遍历echo "<pre>";var_dump(each($arr2)[1]);echo "</pre>";
时间: 2024-11-15 05:25:08