PHP/Data Structure/array search

Материал из Web эксперт
Перейти к: навигация, поиск

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";
}
?>