PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i have a list of about 11000 companies and the state they belong to in a txt file. there are about 300 duplicate company names. i want to find the duplicates names and print them out. (regardless of what state shows next to the name).
the important thing is i need to know which ones have duplicates.
here is what i have now. this is going to run forever. there has got to be a better way.
Use array_unique to create a new, clean (no duplicates) array. Then pass those two arrays through array_diff. You should end up with the duplicate entries.
Try this example. I basically walk the unique array and purge the matching entry in the array that has duplicates. The arrays are passed by doing a copy so the originals are not destroyed by the operation.