Jump to content

delete Dublicates from very large two dimensional array


pilixonis

Recommended Posts

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]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.