May I ask a question about php search?

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.