View Single Post
  #8 (permalink)  
Old 04-18-2008, 03:24 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,158
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Operations in PHP

Searching an array

Searching for a value in an array is made simple using the function array_search(). If the keyword is found in the array, then the corresponding key of that value is retured for further operations.

PHP Code:
<?
$months 
= array(1=>"Jan""Feb""Mar""Apr""May""June""July""Aug",
"Sep""Oct""Nov""Dec");
$key array_search("May"$months); //Searching for May in months array
echo $key;
// We can also print the value that key points at
echo $months[$key];
?>
__________________
With,
J. Jeyaseelan

Everything Possible
Reply With Quote