Look at Array_slice first.
The function of Array_slice is to take a part out of an array, and there are two ways to use it:
$arr =array (' a ' = = ' AA ', ' b ' = = ' BB ', ' c ' + = ' cc ', ' d ' = ' dd ');//start with the 1th data in the array (the array itself starts with 0) and fetch two items. $tmp =array_slice ($arr), Showobj ($tmp);//start with the third data in the array, and fetch two items: $tmp =array_slice ($arr, -3,3); Showobj ($tmp);
Next look at the output:
Array (2) {
["B"]=>
String (2) "BB"
["C"]=>
String (2) "CC"
}
Array (3) {
["B"]=>
String (2) "BB"
["C"]=>
String (2) "CC"
["D"]=>
String (2) "DD"
}
The Showobj function is a var_dump package that is used to print specific objects.
function Showobj ($OBJ) { echo '"; Var_dump ($OBJ); echo "
";}
Here's a look at the Array_flip function:
Array_flip is used to Exchange $arr=array_flip ($arr) of the key values in the array; showobj ($arr);
Output Result:
Array (4) {
["AA"]=>
String (1) "a"
["BB"]=>
String (1) "B"
["CC"]=>
String (1) "C"
["DD"]=>
String (1) "D"
}
The above describes the PHP array functions in the Array_slice and array_flip, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.