how to search for a value in an array php
snippet in php

how to search for a value in an array php

user4035

<?php 
// PHP function to illustrate the use of array_search() 
function Search($value, $array) 
{ 
    return(array_search($value, $array)); 
} 
$array = array("ram", "aakash", "saran", "mohan", "saran"); 
$value = "saran"; 
print_r(Search($value, $array)); 
?>