Hello,
I have below array , I want to search exact key value array form below array and store in new array
the Key are [5] and [4] and value are [S] and [Red]
that keys come dynamically whether it is one or more than two
$variant_array =
Array
(
[566531271473754110] => Array
(
[p_id] => 7113
[vID] => 56
[5] => S
[4] => Red
[1] => 500
[2] => 410
[3] => 15
)
[286531271473754110] => Array
(
[p_id] => 7113
[vID] => 56
[5] => S
[4] => Red
[1] => 500
[2] => 420
[3] => 15
)
[566531311473754110] => Array
(
[p_id] => 7113
[vID] => 56
[5] => M
[4] => Blue
[1] => 500
[2] => 450
[3] => 10
)
[566532101473754110] => Array
(
[p_id] => 7113
[vID] => 56
[5] => XS
[4] => Red
[1] => 500
[2] => 450
[3] => 25
)
)
this is search key value
$val_exp =
Array
(
[0] => S
[1] => Red
)
$key_exp
Array
(
[0] => 5
[1] => 4
)
this is i had try,
foreach($variant_array as $keys=>$vals)
{
foreach($val_exp as $val_key=>$val_val)
{
if($vals[$key_exp[$val_key]] == $val_val && $vals[3] > 0)
{
$available_variant[$keys] = $vals;
}
}
}
Please Solve this.
Our community of experts have been thoroughly vetted for their expertise and industry experience.