I have a PHP array of strings: ie: “Big green car parked outside”..etc
I would like to perform boolean search operations on these strings, similar to MySQL fulltext searching , or Sphinx Searching.
For example, I would like to find all strings containing word “green” but not “car”
Does anyone know of any existing PHP classes or libraries which would help me accomplish this ? Or can anyone suggest any google terms I could search for ?
Thank you in advance!
The PHP function
array_filter()will do the trick here.This checks if the string contains
green, if it doesn’t, exclude it from the array. Then, it checks if it containscar, if it does, exclude it. Otherwise, include it.EDIT: I added spaces in the strings so you wouldn’t match cart as well as car, for example. This is all up to your own preference.