We can search a value into an array to know weither a value exist in an array or not and if it exist then what its key. This is quite easy because we have a function in php to do this searching. You just have to use the function array_search() that’s all we need to do.
We have two parameters in this function in the first one we will write the value that we want to search and in the second parameter we will give the array that we have.
Code Example:
<?php $array = array( "z"=>"banana", "y"=>"apple", "x"=>"lemon" ); echo "You Value Found At Index '".array_search( "apple" , $array )."'"; ?>
Output:
You Value Found At Index ‘y’