PHP Programing language

adplus-dvertising
array_search() Function in PHP
Previous Home Next
adplus-dvertising

array_search()

The array_search() function search an array for a value and returns the key.

Syntax:
array_search(value,array,strict)

In above syntax, "value" specifies the value to search for, "array" specifies the array to search in, and "strict" If this parameter is set to TRUE, then this function will search for identical elements in the array and values are as follows:

  • true
  • false - Default

Example:

<?php
$a=array("a"=>"Apple","b"=>"Mango","c"=>"Banana");
echo array_search("Mango",$a);
?>

Output:

b

Previous Home Next