andrez Posted February 18, 2005 Report Share Posted February 18, 2005 tautua, kaa var dabuuut shaadaa stringaa visu kas ir starp id un .jpg "pic45603id14610.jpg" ja pic45603 cipars var buut arii lielaaks vai mazaaks, piemeeram pic43id34.jpg paldies ! Link to comment Share on other sites More sharing options...
bubu Posted February 18, 2005 Report Share Posted February 18, 2005 (edited) 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 February 18, 2005 by bubu Link to comment Share on other sites More sharing options...
andrez Posted February 18, 2005 Author Report Share Posted February 18, 2005 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); shi te nestraada :/ Link to comment Share on other sites More sharing options...
bubu Posted February 18, 2005 Report Share Posted February 18, 2005 Nez, man gan strādā. Link to comment Share on other sites More sharing options...
Klez Posted February 19, 2005 Report Share Posted February 19, 2005 <? $im = "pic45603id14610.jpg"; $im = explode("id",$im); echo $cipari = substr($im[1],0,-4); //izvadas 14610 ?> vieniigi varbuut nedaudz leeneex. bet straadaa. pie norunas, ja tai stringaa vaf 2 vai varaaki "id" Link to comment Share on other sites More sharing options...
Recommended Posts