PHP, how can I produce a string, a unique list of values up to three items, for use after IN in a query?
- by Jules
I need to produce a string for use in an query e.g.
SELECT whatever from Keywords.word IN (here);
At the moment I have string which could be
$search = "one word or four";
or
$search = "one";
or
$search = "one one";
I need to validate this into some acceptable for my query.
I want a unique list of words, separated with a comma up to a maximum of three.
This is what I have so far.
$array = explode(" ",$search);
$unique = array_unique ($array);
I'm sure there must be a quicker way than evaluating each of the items for blank and selecting the first three.