1.array_shift () Moves the first cell out of the array and returns it, which is sometimes convenient for the first cell of the array to be handled separately.
Copy the Code code as follows:
$tmparray = Array ("1", "2", "3", "4");
$tmparray = Array_shift ($tmparray);
Print_r ($tmparray);
?>
2.array_chunk () splits an array into multiple arrays, followed by parameters that control the number of array cells.
Copy the 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 directly loop, of course, with nested loops can be implemented, but too much trouble, if first used array_chunk () This function first to process and then return the new array, it is very convenient.
3.array_push () presses the incoming value into the end of the array.
Copy the 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 into the array as a whole
Copy the Code code as follows:
$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 remove the weight and return a new
Copy the Code code as follows:
$tmparray = ("a" = "a", "B" = "B", "C" = "C", "D" = "B");
$resarray = Array_unique ($tmparray);//("a" = "a", "B" = "B", "C" = "C");
?>
The above describes the international trade practice case analysis of common array processing methods in PHP example analysis, including the International Trade practice case analysis of the content, I hope the PHP tutorial interested in a friend helpful.