title: How do I use PHP to find if a string contains a specific URL?
body: <p>I want to do a pattern match for certain domain names (using PHP). For example, if I am given a website URL, then I want to determine if that URL is from YouTube. The code below is what I tried, but it doesn't work (the if statement is always false). Any suggestions? Thanks ahead of time!</p>
  
  <pre><code>$website = trim( htmlentities( filter_var($_POST['website'], FILTER_SANITIZE_URL) ) );
  
  if( preg_match("/youtube\.com/i", $website) )
  {
      // do stuff
  }
  </code></pre>