Introducing several very useful "array" functions in php4 1 void extract (array var_array [, int extract_type ][, string prefix]]) expands an associative array into variable names and variable values. If there is a conflict, the following parameters will be used Specify the processing method! For example:
"blue", "size" => "medium", "shape" => "sphere"); extract ($var_array, EXTR_PREFIX_SAME, "wddx"); print "$color, $size, $shape , $wddx_sizen"; ?> 2 array compact (mixed varname [, mixed ...]) Contrary to the above function, save the variable name and variable value into an associative array! For example: $city = "San Francisco"; $state = "CA"; $event = "SIGGRAPH"; $location_vars = array ("city", "state"); $result = compact ("event", "nothing_here" , $location_vars); $result The result is array ("event" => "SIGGRAPH", "city" => "San Francisco", "state" => "CA"). 3 bool in_array (mixed needle, array haystack) Determine whether there is this value in the array 4 void natsort (array array) Sort the array using the natural number method, then 12 will be ranked behind 2 $array1 = $array2 = array ("img12.png", "img10.png", "img2.png","img1.png"); sort($array1); echo "standard sortn"; print_r($array1); natsort($array2); echo "nnatural sortn"; print_r($array2 ); The code output is: Standard sorting Array ( [0] => img1.png [1] => img10.png [2] => img12.png [3] => img2.png ) Natural sorting Array ( [3] => img1.png [2] => img2.png [1] => img10.png [0] => img12.png )