harkly Posted November 15, 2008 Share Posted November 15, 2008 I am doing a search that is similar to imdb.com's. I may be over thinking this but I want to be able to search for a name and not get an error if the user puts in to many spaces. I've used trim() to get rid of any spaces before and after and now I need something for any in the middle. I have looked at using EXPLODE but not sure how to get them back together. Then I was thinking if I used IMPLODE and thought that if I created another column in the table with no spaces that would work. I did try a FULL TEXT SEARCH but that didn't resolve my problem. Can anyone send me in a good direction? Also, I want to be able to pull up data when they misspell the name. I looked at the SOUNDEX but was a bit confused and I want to double check with you guys to see if that may be the direction to go in. Link to comment https://forums.phpfreaks.com/topic/132841-search-advice/ Share on other sites More sharing options...
bobbinsbro Posted November 15, 2008 Share Posted November 15, 2008 for the white space elimination you could use: $string = preg_replace('/\s+/', ' ', $string); //just for the space char or: $string = preg_replace('/[\s\t\n\r]+/', ' ', $string); //for all whitespace chars Link to comment https://forums.phpfreaks.com/topic/132841-search-advice/#findComment-690871 Share on other sites More sharing options...
harkly Posted November 15, 2008 Author Share Posted November 15, 2008 Worked like a Charm!! Thanks!! Any ideas as to what path I should look at for misspellings? Link to comment https://forums.phpfreaks.com/topic/132841-search-advice/#findComment-690878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.