title: PHP: Extract video ID from YouTube URLs
body: <p>Do I do something wrong?
  I need the youtube code, but it doesn't return the real value.</p>
  
  <pre><code>if(preg_match_all("http:\/\/www\.youtube\.com\/v\/(.*)(.*)", $row-&gt;n_texto, $matches){
      $code = $image_to_thumb .= "http://i1.ytimg.com/vi/".$matches[1][0]."/0.jpg";
  }
  </code></pre>
  
  <p><strong>Edit - ircmaxell</strong> Based on the comment, the link structure in the text is:</p>
  
  <blockquote>
    <p>http:// www.youtube.com/v/plMvAh10HVg%26hl=en%26fs=1%26rel=0</p>
  </blockquote>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>The problem is: my code return a link like this:</p>
  
  <pre><code>http://www.youtube.com/v/plMvAh10HVg%26hl=en%26fs=1%26rel=0
  </code></pre>
  
  <p>Can I stop it with regexp before appear <code>%26hl=en%26fs=1%26rel=0</code>?</p>