How to find multiple key/value pair combination array in unother multiple key/value array in php -
i have array list (for example i'm using googles colors). i'm wanting able search multiple key/value pairs if found pair of array return true otherwise return false.
input below color , lenscolor pair : this value dynamic comes dynamic dropdown array ( [color] => tokyo tortoise,matte gold & green [lenscolor] => green )
in array search above color , lenscolor pair this value dynamic comes xml file(converted in array) array ( [0] => array ( [color] => feathered carmel,matte gunmetal & brown [lenscolor] => brown )
[1] => array ( [color] => matte black,matte black & smoke [lenscolor] => smoke ) [2] => array ( [color] => tokyo tortoise,matte gold & green [lenscolor] => green ) [3] => array ( [color] => matte black,matte black & smoke [lenscolor] => green ) [4] => array ( [color] => feathered carmel,matte gunmetal & brown [lenscolor] => green ) [5] => array ( [color] => feathered carmel,matte gunmetal & brown [lenscolor] => smoke ) )
this idea of be, simple:
$arr =array(array ( "color" => "matte black,matte black & smoke", "lenscolor" => "smoke" ), array( "color" => "tokyo tortoise,matte gold & green", "lenscolor" => "green" ), array( "color" => "matte black,matte black & smoke", "lenscolor" => "green" ), array( "color" => "feathered carmel,matte gunmetal & brown", "lenscolor" => "green" ), array( "color" => "feathered carmel,matte gunmetal & brown", "lenscolor" => "smoke" ) ); $founded = false; $color ="tokyo tortoise,matte gold & green"; $lenscolor="green"; echo $color; ($i=0; $i<count($arr);$i++){ if($arr[$i]['color']==$color && $arr[$i]['lenscolor']==$lenscolor){ $founded=true; break; } } echo var_dump($founded); it can make more sofisticated.
Comments
Post a Comment