array_symbol function in php || PHP Functions

array_search function in php

Last Updated by Pooja Chikara 20-Mar-20

0 279


The array_search() function is an inbuilt of PHP which used to search a particular value in an array and return the key. This function return FALSE if the value is not found in the array.

If the value occurs multiple times then it returns the key of value which match first.

array_search function syntax:

array_search(value, array, strict_parameter_value);

Here:

  1. Value indicates the item which we want to search in the array. It is mandatory.
  2. Array is the array in which we want to search item. It is also mandatory.
  3. strict_parameter_value is set the strictness of search. It has two value either TRUE or FALSE. Default value of this parameter is FALSE. It is not mandatory.

array_search function example:

<?php
// This example define the use of array_search() function
$arr=array("coding", "tag", "is", "a", "Prominent", "Portal", "to learn", "latest technologies");
$value="Prominent";
$result=array_search($value,$arr);
echo 'The key of '.$value.' is '.$result;
?>

Output:

array_search function in php


Share:


Leave a Reply


Comments
    Waiting for your comments