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.
|