Home Tutorial Php Phparray PHP Array get key from value

 
 

Share on Google+Share on Google+
PHP Array get key from value
Posted on: October 28, 2009 at 12:00 AM
Advertisement
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
Advertisement

Related Tags for PHP Array get key from value:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 28, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com