php - Key/Value Search in Multidimensional Array -
in building out google feed, needing way return key in multidimensional array age groups based on sizes:
$sizearray = array("newborn" => "0-3m", "infant" => array("3-6m", "6-12m"), "toddler" => array("12-18m", "18-24m", "2t", "3t", "4t", "5"), "kids" => array("6", "7", "8") );
i'm hoping similar this:
findkey("18-24m", $sizearray);
which return: toddler
if there better way this, i'm ears. in advance!
you can this:
$sizearray = array("newborn" => "0-3m", "infant" => array("3-6m", "6-12m"), "toddler" => array("12-18m", "18-24m", "2t", "3t", "4t", "5"), "kids" => array("6", "7", "8") ); foreach($sizearray $key => $array) { if(is_array($array)) { if(array_search('18-24m', $array)) { echo $key; } } }
hope helps! :d
Comments
Post a Comment