Syntax
| array_search($value, $array [,$strict]); |
Definition and Usage
The array_search() function search an array for a value and returns the key.
If value is a string, the comparison is done in a case-sensitive manner.
Paramters
| Parameter | Description |
|---|---|
| value | Required. Specifies a value to be searched. |
| array | Required. Specifies an array. |
| strict | Optional. If it is set to TRUE then the array_search() will also check the types of the search in the array. |
Return Values
Returns the key if it is found in the array, FALSE otherwise.
Example
Try out following example:
<?php
$array=array("a"=>"banana","b"=>"apple","c"=>"orange");
print_r(array_search("apple", $array));
?>
|
This will produce following result:
b |
No comments:
Post a Comment