title: PHP - Search String for a Specific Word Array and Match with an Optional + or -
body: <p>I need to search a string for a specific word and have the match be a variable.  I have a specific list of words in an array:</p>
  
  <pre><code>$names = array ("Blue", "Gold", "White", "Purple", "Green", "Teal", "Purple", "Red");
  
  $drag = "Glowing looks to be +Blue.";
  
  $match = "+Blue";
  
  echo $match
  
  +Blue
  </code></pre>
  
  <p>What I need to do is search <code>$drag</code> with the <code>$names</code> and find matches with an option <code>+</code> or <code>-</code> character and have <code>$match</code> become the result.</p>