Reputation: 786
I've read in a CSV (Comma Delimited Excel Spreadsheet) file and stored it in multiple arrays (one for each column). When people search for "Deniatus Field Hockey Schedule", they get the search result (which is returned via AJAX). When they search for "Deniatus Hockey", they do not see "Deniatus Field Hockey Schedule" as a netted result.
Is there something like the "like" operator used with MySQL that's available for use with PHP arrays?
Upvotes: 0
Views: 268
Reputation: 295
preg_match should do the job. You can look for each word in your string and count the number of matches that you get.
If you want to look for words individually, I suggest doing an explode() using " " as your delimiter so that you get an array of individual words to work with.
Upvotes: 0
Reputation: 17457
If you are searching for the full phrase Deniatus Hockey
, that obviously will not match Deniatus Field Hockey Schedule
. You need to break your search string up and search each word individually.
Upvotes: 0
Reputation: 1772
Why not just loop over the array and check whether the search string occurs (maybe with stripos
)
Upvotes: 1
Reputation: 7597
You can search for strings in strings using stripos
.
You can use it as a callback function looping over all array entries.
Upvotes: 2