In the PHP array, if you want to extract all the key values from the array to form a new array, you can use the Array_keys function.
function usage such as:
Array_keys (Array,value)
This is how it is presented in the list:
The Array_keys () function returns a new array that contains all the key names in the array.
If the second argument is supplied, only the key name of the value is returned.
If the strict parameter is specified as true, PHP uses the congruent comparison (= = =) to strictly check the data type of the key value.
<?php$color=array ("B" = "blur", "P" = "Pink", "R" and "Red");p Rint_r (Array_keys ($color, "Red")); >
Results:
Array ([0] = R)
The strict parameter is specified as false, and PHP does not use the congruent comparison (= = =) to strictly check the data type of the key value.
Use the strict parameter (false):
<?php$num=array ("1");p Rint_r (Array_keys ($num, "1", false));? >
Output:
Array ([0] = 0 [1] = 3)
The strict parameter is specified as true, and PHP uses the congruent comparison (= = =) to strictly check the data type of the key value.
Use the strict parameter (true):
<?php$num=array ("1");p Rint_r (Array_keys ($num, "1", true));? >
Output:
Array ([0] = 3)
Array_keys::P HP All key combinations new array