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
Post a Comment