Function to find particular value or key in the array for php – In_array
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();
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"; } ?>
Explanation:
If you want find a particular key or value in the very long array for any action..
<?php $var = array(‘raj'=>'1233','sekar'=>'434','developer'=>'asd','desks'=>'ded','developerdesks'=>'free','designer'=>'dsa'); ?>
here ‘raj’ is ‘key’ and ‘1233’ is ‘value’
you can search anything value or key using IN_ARRAY();
Similar to In_array();
2. array_search()
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.
You can see Explanation Here