i have the following array:
Array $a
(
[1] => Array
(
[id] => 1
[name] => Shoes
)
[2] => Array
(
[id] => 2
[name] => Shirts
)
[3] => Array
(
[id] => 3
[name] => Jeans
)
)
And i've got this array:
Array $b
(
[0] => [1]
[1] => [5]
[2] => [6]
)
Now i want to find out, if one value of $b matches the [id] in $a. If so i want to add a new value ['hasID'] => true inside $a.
The solutions should look like this:
Array $a
(
[1] => Array
(
[id] => 1
[name] => Shoes
[hasID] => true
)
[2] => Array
(
[id] => 2
[name] => Shirts
[hasID] => false
)
[3] => Array
(
[id] => 3
[name] => Jeans
[hasID] => false
)
)
My try was this:
foreach($a as $ak => $av) {
foreach($b as $bk => $bv) {
if($bv == $ak['id']) {
$a[$ak]['hasID'] == true;
} else {
$a[$ak]['hasID'] == false;
}
}
}
That doesn't work so. I've tried hours. Any ideas?
Thank you very much!
Regards