PHP array
PHP array_keys
PHP array_keys is used to find the key value in the PHP array. It can simply output all the key values, or you can add conditions to let array_keys help you find the specific key value. This array function can only judge the key value of the PHP Array . It is not used to find array elements.
PHP array_keys syntax example
array array_keys (fill in the array to be queried, fill in the specific array element you are looking for);
In the example, the "fill in the array to be queried" is a required item, and it must be a PHP Array . As for "fill in the specific array element you are looking for", it is an optional item to tell PHP array_keys you want To find the specific key value, please refer to the following example.
PHP array_keys implementation example
<?php
$Arr = array("0" => "A", "1" => "B" );
print_r(array_keys($Arr)); // 會輸出 Array ( [0] => 0 [1] => 1 )
$Arr = array("0" => "A", "1" => "B" , "2" => "C" , "3" => "B" );
print_r(array_keys($Arr,B)); // 會輸出 Array ( [0] => 1 [1] => 3 )
?>
The first group of examples does not add any specific conditions, so array_keys directly stores all the key values into an array and then outputs it. This part is relatively no problem. Note that the second group of examples has already added the key with the key value B before outputting. So the final printed result has only two key values.$Arr = array("0" => "A", "1" => "B" );
print_r(array_keys($Arr)); // 會輸出 Array ( [0] => 0 [1] => 1 )
$Arr = array("0" => "A", "1" => "B" , "2" => "C" , "3" => "B" );
print_r(array_keys($Arr,B)); // 會輸出 Array ( [0] => 1 [1] => 3 )
?>
 
 
Post a Comment
0 Comments