I'm learning to code PHP and gave myself a challenge: Filter array data by matching a specific element value for duplication. I went through it logically on paper then wrote code and it worked on the first try :) But I bet it is the most inefficient way, so to learn I would like to compare it against what others would do. Below is my code. The array is just a few elements with keys like name and id. My result is a list of only items with unique ids from an array with many duplicate ids but different names.

Also, part of the challenge was testing XML, JSON, and Arrays so I made the original data XML and used SimpleXML but made a copy of that data as a PHP array and worked with that to do filtering (XPath challenge next).

Thanks for looking and any suggested improvements that I can learn from.