Jump to content
php.lv forumi

stringi...


andrez

Recommended Posts

2 varianti:

ātrs, bet nesmukāks:

 $txt = "pic45603id14610.jpg";
 $p1 = strpos($txt, 'id');
 $p2 = strpos($txt, '.jpg');
 echo substr($txt, $p1+2, $p2-$p1-2);

 

nedaudz lēnāks, bet smukāks:

 preg_match('/id(\d+)\.jpg$/', $txt, $m);
 echo $m[1];

Edited by bubu
Link to comment
Share on other sites

×
×
  • Create New...