title: extracting facebook photo id from a LONG url
body: <p>I have searched this website on how to extract facebook id from url that starts from photo.php?fbid= but i have a long url and know how to get photo id</p>
  
  <p>Example1 : photo.php?fbid=10151987845617397 (the complete url is stored in the $url variable which is checked using preg_match i believe)</p>
  
  <pre><code>!preg_match("|^http(s)?://(www.)?facebook.com/photo.php(.*)?$|i", $url) || !$pid
  </code></pre>
  
  <p>the above code fetches facebook id 10151987845617397 and puts it in the variable $pid.</p>
  
  <p>If I have a long url, how can i change the code?
  Here is the url
  Example2 : <a href="https://www.facebook.com/nokia/photos/a.338008237396.161268.36922302396/10151987845617397/?type=1&amp;theater" rel="nofollow">https://www.facebook.com/nokia/photos/a.338008237396.161268.36922302396/10151987845617397/?type=1&amp;theater</a>
  In the above url 10151987845617397 is the photo id that i need to capture and put it in variable $pid.</p>
  
  <p>what changes do i need to do in the preg_match string?</p>
  
  <p>In other words to get the photoid 10151987845617397 as output in the $pid variable:</p>
  
  <p>For url facebookcom/photo.php?fbid=10151987845617397
  The syntax is !preg_match("|^http(s)?://(www.)?facebook.com/photo.php(.*)?$|i", $url) || !$pid</p>
  
  <p>So for url facebookcom/nokia/photos/a.338008237396.161268.36922302396/10151987845617397/?type=1&amp;theater
  What would be the syntax</p>
  
  <p>Please help
  Thanks</p>