Skip to content
Advertisement

In PHP, for a specific key in an associative array, find identical keys and combine values into a single string variable

I have found many references for similar questions on SO but nothing close to what I’m trying to do. I have this array output:

JavaScript

I would like to now use ‘kp_uid’ to locate all common values and then combine the ‘full_name’ values for each key into a string (with comma separation). Desired outcome from above example will be:

JavaScript

I have tried many ideas gathered from SO and this was the closest but I can’t separate out the unique key:

JavaScript

Partial results from this show all four names:

JavaScript

Any direction here will be appreciated. Thank you.

Advertisement

Answer

JavaScript

This returns desired result. I left a few comments in the code for clarity.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement