1.array_shift()将数组的第一个单元移出再返回,这对有时候数组的第一个单元要单独处理很方便。
复制代码 代码如下:
$tmparray = array("1", "2", "3", "4");
$tmparray = array_shift ($tmparray);
print_r($tmparray);
?>
复制代码 代码如下:
$tmparray = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($tmparray, 2));
?>
复制代码 代码如下:
$tmparray = array ("a", "b");
array_push ($tmparray, "c", "d");
print_r($tmparray);//Array([0] => a[1] =>b[2] =>c[3] =>d)
?>
复制代码 代码如下:
$tmparray= array ("a", "b");
$resarray = array_unshift ($tmparray, "c", "d");
print_r($resarray )//Array([0] => a[1] =>b[2] =>c[3] =>d)
?>
复制代码 代码如下:
$tmparray = ("a" => "a","b" => "b","c" => "c","d" => "b");
$resarray = array_unique($tmparray);//("a" => "a","b" => "b","c" => "c");
?>