If you just want to use a search library that gives you word proximity (and more), it would be a lot less work to look at existing open source implementations. Xapian and Lucene are both quite useful and can be invoked from PHP, among other languages.
http://www-csli.stanford.edu/~hinrich/information-retrieval-...
If you just want to use a search library that gives you word proximity (and more), it would be a lot less work to look at existing open source implementations. Xapian and Lucene are both quite useful and can be invoked from PHP, among other languages.