How to use array search in PHP

In this article, I will explain how the array_search() function can be used in PHP.
  • 1819

array_search() function in PHP

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

  • In array_search() function, the comparison is done in a case-sensitive manner, If value is a string,




  • value value is required parameter. Determine value to be searched.

  • array  array is required parameter. Specifies an array.

  • strict strict is optional parameter. Possible values:

    • true
    • false - Default


The following example show to how the array_search() function can be used in PHP.



<h3 style="color: blue;">array_search() function example in PHP</h3>  



    echo"Search Element Key is : ";

    print_r(array_search("Student", $array));







You may also want to read these related articles here

Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.