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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.