1. Array function/function: provides many useful code snippets written by the official, improve the writing speed
1) Array of key-value manipulation functions
Array_values ();//Gets the value in the array
Array_keys ();//Gets the keys in the array
In_array ();//Check if a value is in the array
Array_flip ();//Key and value swap
Array_reverse ();//The values in the array are reversed
Simulation gets the value of key
<?Php$arr=Array ("name"="User1"," Age"=" -","Sex"="nan");foreach($arr as$key =$val) {$keys []=$key; Echo $key."<br>";} Print_r ($keys);?>The result of the operation is Nameagesexarray ([0] = = Name [1] = age [2] = + Sex)
<?php
$arr =array
("Name" = "user1", "age" = "+", "sex" = "Nan");
Print_r (Array_keys ($arr));
?>
When you use a function. Execution results are
Array ([0] = = Name [1] = age [2] = = Sex)
The effect is the same.
In the PHP help document, the brackets indicate that the parameter is optional
2) elements and uniqueness of the statistical array
COUNT ()//number of statistical arrays
array_count_values//the number of duplicate values in the statistics array
array_unique//Remove Duplicates
3) functions for handling arrays using callback functions
Array_filter ()//array value filtering
Array_map ()//function The callback function on the cell of the given array
4) Sorting Functions for arrays
sort//sort the array by value, ascending, not preserving key
rsort//sort the array values by value, descending, not preserving key
asort//sort the array values by value, ascending, preserving the key value
arsort//sort the array values by value, descending, preserving the key value
Ksort ()//key sort
Krsort//key sort
natsort//Natural number Sorting
natcasesort//ignoring case natural number ordering
array_multisort//the sorting of multidimensional arrays
5)
6)
7)
8)
2. String functions
PHP array Key-value operations and arrays of statistical functions-functions