PHP Array Learning Record (1)
Some methods for arrays
$test _arr = Array (' name ' = = ' Test ', 2 = 2, ' color ' = ' red '); Echo ' uses the Var_dump method to output an array: '; Var_dump ($test _arr); Echo '
Output array using the Print_r method: ';p rint_r ($test _arr), if (Is_array ($test _arr)) {echo "
$ test_arr is an array ";} echo "
Array_push Add item in array "; Array_push ($test _arr,array (' good ', ' nice '), ' three ', ' four '); Var_dump ($test _arr); echo"
Array_pop usage "; Array_pop ($test _arr);p rint_r ($test _arr); echo"
Array_shift returns the first element in the array "; $b = Array_shift ($test _arr);p rint_r ($b); echo"
Array_unshift: "; Array_unshift ($test _arr, ' unshift ');p rint_r ($test _arr); echo"
Array_pad: "; $c = Array_pad ($test _arr,-7, ' Xiang ');p rint_r ($c); echo"
In_array: "If (In_array (2, $test _arr)) {echo ' In_array through validate ';} Else{echo ' validate die. ';} echo "
Array_keys: Returns the array key name combined into a set: "; $allmarke = Array_keys ($test _arr); Var_dump ($allmarke);
Ready to be perfected