php - How do I get the index of a sub-document retrieved from a query? -


i have code:

'items' =>     array (        0 =>            array (                   'name' => 'paste',                'qty' => 5,                'price' => 2.5,            ),       1 =>            array (                'name' => 'soap',                'qty' => 5,                'price' => 2.5,           ),        ) 

i trying write query find out index of value sub-document items has data entry of name "soap". can me working solution?

i think you're after along lines of

foreach($items $key => $value){    if($value['name'] == "soap") $output = $key; } 

where $output key of array item set soap


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -