How to use array keys in PHP
In this article, I will explain how the array_keys() function can be used in PHP.
array_keys() function in PHP
-
The array_keys() function returns an array containing the keys.
-
The array_keys() function returns the keys as numeric and string from the input array.
-
The array_keys() function is used to get all the keys of an array.
Syntax
Parameter
Example
The following example show to how the array_keys() function can be used in PHP.
<html>
<body>
<h3 style="color: darkslateblue;">array_keys() function example in PHP</h3>
<?php
$a=array("a"=>"student","b"=>"teacher","c"=>"advocate");
print_r(array_keys($a));
$a=array("a"=>"student","b"=>"teacher","c"=>"advocate");
print_r(array_keys($a,"student"));
$a=array(10,20,30,"10");
print_r(array_keys($a,"10",false));
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here