如何找出多维数组的数组索引,只知道一些值? 比如'id'=>'Id2'

$menu = array(
  array ('id' => 'Id1', 'catagory' => 'animals', 'info' => 'olives', 
         'image'=>'images/s1.jpg', 'price' => 2.00),
  array ('id' => 'Id2','catagory' => 'animals', 'info' => 'chicken',
         'image'=>'images/s2.jpg', 'price' => 3.00),
  array('id' => 'Id3','catagory' => 'animals', 'info' => 'soup of the day',
         'image'=>'images/s3.jpg', 'price' => 4.00)     
)

If i understand your question well, try this:

$menu = array(
  array ('id' => 'Id1', 'catagory' => 'animals', 'info' => 'olives', 
         'image'=>'images/s1.jpg', 'price' => 2.00),
  array ('id' => 'Id2','catagory' => 'animals', 'info' => 'chicken',
         'image'=>'images/s2.jpg', 'price' => 3.00),
  array('id' => 'Id3','catagory' => 'animals', 'info' => 'soup of the day',
         'image'=>'images/s3.jpg', 'price' => 4.00)     
);

echo getIndexByValue($menu, "Id1"); //returns 0
echo getIndexByValue($menu, "images/s3.jpg"); //returns 2
echo getIndexByValue($menu, "qwerty"); //returns -1

function getIndexByValue($menu, $value)
{
    foreach($menu as $index => $subMenu)
    {   
        if(in_array($value, $subMenu))
        {
            return $index;
        }
    }
    return -1;
}

EDIT

If you want to use a key/value pair like id=>Id1 you can use something like this:

echo getIndexByKeyValue($menu, array('id'=>'Id1')); //returns 0
echo getIndexByKeyValue($menu, array('id'=>'Id2')); //returns 1
echo getIndexByKeyValue($menu, array('id'=>'qwerty')); //returns -1

function getIndexByKeyValue($menu, $keyValue)
{
    foreach($menu as $index => $subMenu)
    {   
        if(array_key_exists(key($keyValue), $subMenu) && $subMenu[key($keyValue)] == $keyValue[key($keyValue)])
        {
            return $index;
        }
    }
    return -1;
}