PHP search engine based on text files

Source: Internet
Author: User
Tags explode
This article mainly introduces the text file-based PHP search engine, has a certain reference value, now share to everyone, the need for friends can refer to

PHP search engine based on text files

下面是我从zend.com找来的以文本为基础的PHP搜索引擎源代码,并做了点无干紧要的修改:
search.php

  
Search engine |http://www.yahoo.com| great search engine, Almost everything can be found here. The
Movie |http://movies.yahoo.com| popular movies, box office receipts, and upcoming new movies.
Stock |http://quote.yahoo.com| can look at the stock market, the foreign market website.
Linux|http://www.linuxcentral.com| If you want to buy some Linux products, you may wish to come here.
Linux|http://www.linux.org| A large number of applications, articles, and so on. The
Linux|http://www.linuxtoday.com|linux news station lists the latest Linux news.
zdnet|http://www.zdnet.com| News and download station. The
apache|http://www.apache.org| popular Web server.


This code works like this:

1. Open the text file containing the data, keywords, URLs, descriptions are all separated by |
2. Assign the contents of this file to the variable $FR;
3. The value of the explode () output is assigned to the $line variable;
4. Use explode () to repeat the $line variable, assign the element that is separated by | To the lin[] array;
5. Then compare keywords to lin[0],
6. If the match is output--php will output LIN[1], because this is the URL, so the <a href></a> tag should be added;
7. Another very cool variable is $id, if the keyword and lin[0] comparison mismatch, and $id will be equal to &line, and then tell you can not find:)

in Oso I also see another piece of code that is more similar, and the implementation method is much the same.
Related Article

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.