If we have a very large array values in Indexed or Associative array, we have to search or filter the particular array value or key.
Array_Search function is used to find the value.
This function used to search an array for a value and returns the key.
<?php $search =array('a'=>'php','b'=>'css','c'=>'html,'d'=>'dssd','e'=>'eeee',f=>'fdfd','g'=>'dsfsd',....); echo array_search('css',$search); ?>
In the Given example, we have to find whether “CSS” Find or not in the array. It prints the key of the value.
Output
b // output
Explaination
array_search is used to search the array value(‘css’) and returns the value’s key(‘b’);
2. In_array()
In_array is simillar to the array_search
In_array Functions is used to find the value in the array list
using this function you can find the value is present or not in array queue.
syntax: In_array();
you can search anything value or key using IN_ARRAY();
for example
have to find “Developerdesks” in the given array
<?php $var = array(‘raj’,’sekar’,’developer’,’desks’,'php','html','css','developerdesks','designer'); if(in_array('developerdesks', $var, )) { echo "found Developerdesks"; } else { echo "not found"; } ?>
You can see explanation in this url