标签:数组去重 删除 uniq php基础 array get 关联 可变 merge
//参数默认值
// 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>";
标签:数组去重 删除 uniq php基础 array get 关联 可变 merge
原文地址:http://www.cnblogs.com/ping04/p/7600916.html