从php URL字符串中获取变量

What's the easiest way to grab a 6-character id from a string?

The id will always be after www.twitpic.com/ and will always be 6 characters.

e.g., $string = 'The url is http://www.twitpic.com/f1462i.  Enjoy.';
      $id = 'f1462i';

Thanks.

  $string = "http://www.twitpic.com/f1462i" ;
  $id = substr($string,strpos($string, 'twitpic.com')+strlen('twitpic.com')+1,6) ;
  echo $id ;
preg_match("@twitpic\.com/(\w{6})@", "The url is http://www.twitpic.com/f1462i.  Enjoy.", $m);
$id = $m[1];

Here you go. Complete working code without regex :

<?php
$string = 'The url is http://www.twitpic.com/f1462i.  Enjoy.';
$id = substr($string, strpos($string, 'http://www.twitpic.com/')+23, 6);
echo $id;   //output: f1462i
?>