I have a small script which searches an ODBC database, and I would like to be able to enter in any search string, and take this string and manipulate so it searches the database in many different ways. When I use LIKE in my SQL query on a MySQL database, I don't have to do this, since it returns all matches regardless of capitilization. However my ODBC database, (Informix 5 on SCO UNIX) seems to be picky. It only seems to match the case of your input.
Here is what I have so far:
$desc1 = ucfirst($desc);
$desc2 = strtoupper ($desc);
$parts = explode(" ",$desc);
for($i = 0; $i < count($parts); $i++)
{
$parts[$i] = ucfirst($parts[$i]);
}
$desc3 = join(" ",$parts);
$desc4 = strtolower($desc);
This does a good job at matching most things, but I would like to do some further matching, which the above does not catch. The majority of the records in the db have all capitals, so $desc2 usually matches 95% of the records in the search. I do have a few instances where the record will contain something like:
McClure
McDONALDS
Mc Donalds
Mac Donald
MacDONALD
I'm not sure how to handle situations like that. Is there a PHP function, or how would I manipulate my string so that I can rewrite the input string (all lowercase) to match those possibilities?
Thanks for any help.
Bruce