I’ve looked through the built in array functions and I can’t seem to find something to do what I want.
I have two arrays. One is built from a MySQL many-to-many relationship result set that looks like this:
Array
(
[0] => Array
(
[id] => 1
[name] => Jeff
=>
)
[1] => Array
(
[id] => 2
[name] => Dan
=>
)
[2] => Array
(
[id] => 3
[name] => Bob
=> SBP
)
[3] => Array
(
[id] => 3
[name] => Bob
=> SB
)
[4] => Array
(
[id] => 3
[name] => Bob
=> PB
)
)
The second is a list of the codes table:
```php
Array
(
[0] => Array
(
=> SBP
)
[1] => Array
(
=> SB
)
[2] => Array
(
=> PB
)
[3] => Array
(
=> OSB
)
)
What I want to end up with is one array that merges all of the codes into the keys for each person and if that person has a code then it assigns a value of ‘Y’. For example, how do I go about getting my array to look exactly like this:
Array
(
[0] => Array
(
[id] => 1
[name] => Jeff
[SBP] =>
[SB] =>
[PB] =>
[OSB] =>
)
[1] => Array
(
[id] => 2
[name] => Dan
[SBP] =>
[SB] =>
[PB] =>
[OSB] =>
)
[2] => Array
(
[id] => 3
[name] => Bob
[SBP] => Y
[SB] => Y
[PB] => Y
[OSB] =>
)
)