Home Tutorial Php Phparray PHP Array get key from value

 
 

PHP Array get key from value
Posted on: October 28, 2009 at 12:00 AM
This section illustrates how to get the key from the array for the given value

  • In php array one can get the key from value by the use of array_search function
  • Array_search function searches the key for the given values in the array.


Example of PHP Array Get Key from Value
<?php
$product
=array("n"=>"newyork","c"=>"cylone","t"=>"tokyo","New Delhi","d"=>"dhaka");
$k
=array_search("cylone",$product);
echo
"key of cylone is ".$k;
?>

Output
key of cylone is c

Related Tags for PHP Array get key from value:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.