PHP Programing language

array_keys() Function in PHP
Previous Home Next

array_keys()

The array_keys() function returns an array containing the keys.

Syntax:
array_keys(array,value,strict)

In above syntax,"array" specifies an array, "value" specifies the value then only the keys with this value are returned, "strict" is used with the value parameter and values are as follows:

  • true - Returns the keys with the specified value, depending on type: the number 5 is not the same as the string "5".
  • false - Default value. Not depending on type, the number 5 is the same as the string "5".

Example:

<?php
$a=array("Apple"=>"fruit","Mango"=>"fruit","Banana"=>"fruit");
print_r(array_keys($a));
?>

Output:

Array ( [0] => Apple [1] => Mango [2] => Banana )

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: