1.array_shift () Moves the first cell of the array back again, which is convenient for the first unit of the array to be processed separately.
Copy Code code as follows:
?
$tmparray = Array ("1", "2", "3", "4");
$tmparray = Array_shift ($tmparray);
Print_r ($tmparray);
?>
2.array_chunk () divides an array into multiple arrays, followed by a parameter that controls the number of array cells.
Copy Code code as follows:
?
$tmparray = Array (' A ', ' B ', ' C ', ' d ', ' e ');
Print_r (Array_chunk ($tmparray, 2));
?>
This function works well in some loops, such as I want to put the obtained data into n rows, m columns. If we do not cycle directly, of course, with nested loops can be implemented, but too troublesome, if the first use of array_chunk () This function first processing and then return the new array, it is very convenient.
3.array_push () presses the passed-in value into the end of the array.
Copy Code code as follows:
?
$tmparray = Array ("A", "B");
Array_push ($tmparray, "C", "D");
Print_r ($tmparray);//array ([0] => a[1] =>b[2] =>c[3] =>d)
?>
4.array_unshift () Inserts the incoming cell as a whole into the array
Copy Code code as follows:
<?php
$tmparray = Array ("A", "B");
$resarray = Array_unshift ($tmparray, "C", "D");
Print_r ($resarray)//array ([0] => a[1] =>b[2] =>c[3] =>d)
?>
5.array_unique the array to go heavy and return a new one
Copy Code code as follows:
.
$tmparray = ("A" => "a", "B" => "B", "C" => "C", "D" => "B");
$resarray = Array_unique ($tmparray);//("A" => "a", "B" => "B", "C" => "C");
?>