rosepanter
New Member
I am using this function in my form to handle text conversion. This is an internal (workplace) web form. It converts\[quote\] main st./grand ave. -> Main St./Grand Ave.
apt. #a1 -> Apt. #A1
1234 w. main st (childrens park) -> 1234 W. Main St (Childrens Park)
smith-o'rourke -> Smith-O'Rourke
mcbride-macgregor -> McBride-MacGregor
macias-machado -> MacIas-MacHado.\[/quote\]Hence, my problem!!How do I include a filter list of names or words that should not be converted, such as Macias, Macayo, Machado, Mack, machine, etc.?\[code\]function uc_names($name_text) { $name_text = strtolower($name_text); $name_text = join("#", array_map('ucwords', explode("#", $name_text))); $name_text = join("/", array_map('ucwords', explode("/", $name_text))); $name_text = join("(", array_map('ucwords', explode("(", $name_text))); $name_text = join("'", array_map('ucwords', explode("'", $name_text))); $name_text = join("-", array_map('ucwords', explode("-", $name_text))); $name_text = join("Mc", array_map('ucwords', explode("Mc", $name_text))); $name_text = join("Mac", array_map('ucwords', explode("Mac", $name_text))); return trim($name_text); }\[/code\]
apt. #a1 -> Apt. #A1
1234 w. main st (childrens park) -> 1234 W. Main St (Childrens Park)
smith-o'rourke -> Smith-O'Rourke
mcbride-macgregor -> McBride-MacGregor
macias-machado -> MacIas-MacHado.\[/quote\]Hence, my problem!!How do I include a filter list of names or words that should not be converted, such as Macias, Macayo, Machado, Mack, machine, etc.?\[code\]function uc_names($name_text) { $name_text = strtolower($name_text); $name_text = join("#", array_map('ucwords', explode("#", $name_text))); $name_text = join("/", array_map('ucwords', explode("/", $name_text))); $name_text = join("(", array_map('ucwords', explode("(", $name_text))); $name_text = join("'", array_map('ucwords', explode("'", $name_text))); $name_text = join("-", array_map('ucwords', explode("-", $name_text))); $name_text = join("Mc", array_map('ucwords', explode("Mc", $name_text))); $name_text = join("Mac", array_map('ucwords', explode("Mac", $name_text))); return trim($name_text); }\[/code\]