title: extracting a youtube URL from a string
body: <p>What I've tried so far is this function:</p>
  
  <pre><code>function isYoutubeUrl($url) {
      return preg_match("#^https?://(?:www\.)?youtube.com#", $url);
  }
  </code></pre>
  
  <p>But it's only working with a plain youtube string like that:</p>
  
  <pre><code>$string = 'http://www.youtube.com/watch?v=bJIXm6U4df';
  $newString = isYoutubeURL($string);
  if($newString); // true
  </code></pre>
  
  <p>I need a function which checks a string for a youtube URL and if there is one, return the url.</p>
  
  <pre><code>$string = 'this is so crazy...http://www.youtube.com/watch?v=bJIXm6U4df';
  $newString = extractYoutubeUrl($string);
  echo $newString; // http://www.youtube.com/watch?v=bJIXm6U4df
  </code></pre>
  
  <p>Any idea?</p>