Php Array Keys Function

What is array_keys Function?


The "array_keys" function returns all keys for a given array.


array_key(array, value, strict)

In the above syntax the "array" is the array of which all keys are displayed,there are two optional fields "value", where one can specify the values of keys to be displayed, "strict" can be "true" or "false" ,if set to "true" function will do a strict comparison.

Example :

$a = array(0 => 100, "color" => "red");
print "<br>";
$b = array(20,40,30,"20");
Result :

Array ( [0] => 0 [1] => color )
Array ( [0] => 0 [1] => 3 )

In the above example the array "$a", all the keys are displayed, but in the array "$b" only the keys of two values 20, "20" are displayed, and the matching is not done striclty as the value given is "False".

PHP Topics

Ask Questions

Ask Question