pilixonis Posted September 6, 2011 Share Posted September 6, 2011 Hello, I have a two dimension array of the following type id, phone, firstname, lastname row1:1, 2342, etc, etc row2:2, 2352, etc, etc The array has at least 100000 rows and i need to delete the rows where the phone is dublicate with other row(phone). i tried in_array and array_intersect but it seems to be very slow ( Any suggestions? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/246531-delete-dublicates-from-very-large-two-dimensional-array/ Share on other sites More sharing options...
voip03 Posted September 6, 2011 Share Posted September 6, 2011 http://stackoverflow.com/questions/1247950/how-to-remove-duplicated-2-dimension-array-in-php Quote Link to comment https://forums.phpfreaks.com/topic/246531-delete-dublicates-from-very-large-two-dimensional-array/#findComment-1265917 Share on other sites More sharing options...
Adam Posted September 6, 2011 Share Posted September 6, 2011 That's because PHP isn't built for handling such large data sets. You're better off doing this on the database side. You can remove duplicates like so (imagining your table is called "contacts"): delete from contacts c1 using contacts c1, contacts c2 where c1.id != c2.id and c1.phone = c2.phone Quote Link to comment https://forums.phpfreaks.com/topic/246531-delete-dublicates-from-very-large-two-dimensional-array/#findComment-1265918 Share on other sites More sharing options...
pilixonis Posted September 7, 2011 Author Share Posted September 7, 2011 Thank you very much for your reply:))) I thought it would be better on the database side but i was wondering if there is a fast way of doing this immediately while i am uploading the array.. Quote Link to comment https://forums.phpfreaks.com/topic/246531-delete-dublicates-from-very-large-two-dimensional-array/#findComment-1266324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.