This section describes several new functions of the array library. We don't have much PHP information on hand. do you have a copy of php4gb. chm. I like the function library in it most, and it provides online help. However, PHP is developing too fast. we don't have much PHP information on hand. do you have a copy of php4gb. chm. I like the function library in it most, and it provides online help. However, PHP is developing too fast. you know, I recently found some extended array functions at www.php.net/manual.
Let me introduce them to you. I have a low level of English. please correct me if the translation is incorrect.
The format is as follows:
Supported function name versions
Function declaration
Description and parameters and return values
Example
OK, Let's go.
//*************************
Array_flip (PHP4> = 4.0b4)
Array array_flip (array trans)
Switch the key and value of the array trans, that is, change the key to the value, and change the value to the key.
Returns the array of processed items.
Example:
$ A [0] = "abc ";
$ A [1] = "def ";
After an array_flip () you get:
$ A ["abc"] = 0; $ a ["def"] = 1;
//***************************
Array_count_values (PHP4> = 4.0b4)
Array array_count_values (array input)
Counts the number of values in the input array. Returns an array with the input value as the key and a new array with the number as the value.
Example:
$ Array = array (1, "hello", 1, "world", "hello ");
Array_count_values ($ array );
// Returns array (1 => 2, "hello" => 2, "world" => 1)
//*****************************
Array_merge (PHP4)
Array array_merge (array array1, array array2 [, array...])
Merge multiple arrays and add the contents of array2 to the end of array1. Returns an array of results.
If it is an associated array, the string is the key, and the key with the same name appears, the subsequent will overwrite the previous one, and the subscript array will not overwrite, just add it to the back.
Example:
$ Array1 = array ("color" => "red", 2, 4 );
$ Array2 = array ("a", "B", "color" => "green", "shape" => "trapezoid", 4 );
Array_merge ($ array1, $ array2 );
// Resulting array will be array ("color" => "green", 2, 4, "a", "B", "shape" => "trapezoid ", 4 ).
See also array_merge_recursive ().
//******************************
Array_merge_recursive (PHP4> = 4.0.1)
Array array_merge_recursive (array array1, array array2 [, array...])
Recursively merges arrays, which is similar to the previous function. The difference is that it does not simply merge the same key, or generate a two-dimensional array to merge the values of the same key. (Sorry, let's look at the example ).
Example:
$ Ar1 = array ("color" => array ("favorite" => "red"), 5 );
$ Ar2 = array (10, "color" => array ("favorite" => "green", "blue "));
$ Result = array_merge_recursive ($ ar1, $ ar2 );
// Resulting array will be array ("color" => array ("favorite" => array ("red", "green"), "blue"), 5, 10 ).
Do you understand? Red and green are merged into a new array and placed in favorite.
See also array_merge ().
//*******************************
Array_intersect (PHP4> = 4.0.1)
Array array_intersect (array array1, array array2 [, array...])
Returns a new array containing the intersection elements.
It is based on array1, so if it is an associated array, the key value is of array1. See the example.
Bytes. I like the function library in it most, and it provides online help. But PHP is developing too fast ,...