yada
$data = 'thumbs/5/0/2/21972_2.jpg';

preg_match_all('#thumbs/(.*?)/(.*?)/(.*?)/(.*?)_(.*?).jpg#si',$data,$gelen);

for($x=0; $x<count($gelen['5']); $x++):
echo $gelen['5'][$x] . '.jpg<br />';
endfor;