Can php filter words in a string while converting the remainder of the string
<p>I am using this function in my form to handle text conversion.  This is an internal (workplace) web form.  It converts</p>

<blockquote>
  <p>main st./grand ave. -> Main St./Grand Ave.<br>
  apt. #a1 -> Apt. #A1<br>
  1234 w. main st (childrens park) -> 1234 W. Main St (Childrens Park)<br>
  smith-o'rourke -> Smith-O'Rourke<br>
  mcbride-macgregor -> McBride-MacGregor<br>
  macias-machado -> MacIas-MacHado.</p>
</blockquote>

<p>Hence, my problem!!</p>

<p>How do I include a filter list of names or words that should not be converted, such as Macias, Macayo, Machado, Mack, machine, etc.?</p>

<pre><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></pre>
