Fastest way to check array items existence in mySQL table

Posted by Enrique on Stack Overflow See other posts from Stack Overflow or by Enrique
Published on 2010-04-12T21:37:26Z Indexed on 2010/04/12 22:13 UTC
Read the original article Hit count: 308

Filed under:
|
|
|
|

User writes a series of tags (, separated) and posts the form.
I build an array containing the tags and delete dupes with array_unique() php function.

I'm thinking of doing:

  • go through the array with foreach($newarray as $item) { ... }
  • check each $item for existence in the tags mySQL table
  • if item does not exists, insert into tags table

Is there a FASTER or MORE OPTIMUM way for doing this?

© Stack Overflow or respective owner

Related posts about foreach

Related posts about php