i'm trying to combine $regex and $in to do simple search.
For example I have a user query of this kind :
$user_query = "for focus red";
In my mongodb collection for each document I have a keywords field. I want to get to get the document where the field keywords is :
{
keywords :
[0] => ford,
[1] => focus,
[2] => red
}
As you can see the user has done a mistake and typed "for" instead of "ford".
I can get the results with $in if the user types Ford, but I don't know how to combine $regex and $in, I have looked the mongodb doc and php mongo doc.
$regexand$in? Please add the related code to your question that shows more about these variables or if it's part of a mongo query, please show the query and the code related to the query.$inand$regexare not PHP variables, they are search operators for MongoDB queries. You're asking him to answer his own question. He said he doesn't know how to write the query.