Ask a php search question, for example, if I enter the keyword & nbsp; "& nbsp; Sincerely & nbsp;" & nbsp; I have already found this sentence for you. how can I use php to implement it? Please answer your questions. ------ Solution ------------------ reference: Quote: reference: $ ar & nbsp; preg_split (ask a question about php search.
For example, if I enter the keyword "sincerely", I can find out the sentence "I have already given my heart to you". how can I use php to implement this? Please answer your questions.
------ Solution --------------------
Reference:
Quote: reference:
$ Ar = preg_split ("// u", 'true',-1, PREG_SPLIT_NO_EMPTY );
$ Where = array ();
Foreach ($ ar as $ v)
$ Where [] = "field like '% $ v % '";
$ SQL = "select * from tt ";
$ SQL. = empty ($ where )? '': 'Where'. join ('and', $ where );
Echo $ SQL;
Does this search all fields with "true" and all fields with "heart?
In fact, my expected result is: if this field only contains one "true" character, this field will not be searched, for example, "I really like", this field will not be found, or "I'm in a good mood" won't be found.
However, fields including "true" or "true" and "heart" will be searched.
For example, I really like it. This sentence will be found. Or the phrase "I have already given my heart to you" will also be found.
This problem occurs when it is used to search products on the office supplies sales website.
Why not give it a try first?