I've got a permissions/group based setup that I'm trying to merge results on. For example, a user might be associated with four groups:
| username | passwd | email | groups |
| test_user | 9agb9 | [email protected] | g1, g2, g3, g4 |
grouping table:
| group | perm1 | perm2 | perm3 | perm4 | perm5 | perm5 | perm7 |
| g1 | 1 | 0 | 0 | 0 | 1 | 0 | 2 |
| g2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| g3 | 0 | 1 | 0 | 0 | 2 | 0 | 0 |
| g4 | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
I'm looking to take the results of those four rows (stored as an array from a DB query) and merge them down to one array, which would look like this:
| group | perm1 | perm2 | perm3 | perm4 | perm5 | perm5 | perm7 |
| combined | 1 | 1 | 0 | 1 | 2 | 1 | 2 |
The highest value from each array becomes the value in the combined array. If 1 out of 100 records is "2" and the rest are "1" or "0" then I'd need "2" to be in the result.
I've looked at array_merge, but it keeps the value depending on the order of variables specified to the function.