array_search() will return the array key if found the given value. This function is case sensitive to strings.
<?php
$my_array = array('1', 'kuppiya', 'Tom', 'Hello');
$key = array_search('Tom', $my_array);
if($key === false)
{
echo 'Not found';
}
else
{
echo $my_array[$key];
}
?>
No comments:
Post a Comment