Search for a string or part of string in PHP

后端 未结 7 1651
春和景丽
春和景丽 2020-12-06 16:14

I am doing a very small online store application in PHP. So I have an array of maps in PHP. I want to search for a string (a product) in the array. I looked at array_search

相关标签:
7条回答
  • 2020-12-06 17:16

    Unfortunately, search is one of the more difficult things to do in computer science. If you build for search based on literal string matches or regular expressions (regex), you may find that you'll be unhappy with the relevance of the results that are returned.

    If you're interested in rolling up your sleeves and getting a little dirty with a more sophisticated solution, I'd try Zend's Lucene implementation ( http://framework.zend.com/manual/en/zend.search.lucene.html ). I've implemented a search on a site with it. It took a few days, but the results were MUCH better than the 15 minute solution of literal string matching.

    Let me know if you'd like more info.

    Best of luck!

    PS. Here's an example: http://devzone.zend.com/article/91

    0 讨论(0)
提交回复
热议问题