I'm rather surprised PHP doesn't have a built-in function to check if two arrays are the same and returns a boolean.
My situation is as follows:
I have a webpage where an user can modify a software list for a computer lab. On one side is the master list, and on the other is the current software list. The user can add and remove from the current list then clicks a button to submit it.
In my code I have the script query the database, retrieve the current software list (the original), and put the data into an array. The script then takes the list new list and also puts it into an array.
Originally, I had the script just delete whatever was in the table and just re-insert the records based on the new list, but this is obviously not the "proper" way to do it, so I'm revisiting the script to make it better.
I want to first compare the two arrays to even see if there's a change. If not, then don't do any work and just return a message to the user. Otherwise, I want to compare the original list to the new list. Whatever is on the original but not on the new would be deleted from the database, and whatever is on the new but not on the original would be added.
I've browsed the pages at php.net and tried some of the things people have posted, but nothing seems to compare two arrays 100% accurately. I find it ironic with all the obscure functions PHP has, there isn't one for this. Or is there? Am I just blind?
I've looked into array_diff but it doesn't really do what I want it to (plus it maintains the array's keys which is annoying).
Any help would be appreciated, thank you for your time.