Finding an element with a particular value : array_search « Data Structure « PHP






Finding an element with a particular value

 
<?
$meals = array('A' => 1,
               'B' => 4.95,
               'C' => 3.00,
               'D' => 6.50,
               'E' => 0); 

$dish = array_search(6.50, $meals);
if ($dish) {
    print "$dish costs \$6.50";
}
?>
  
  








Related examples in the same category