andrez Posted February 18, 2005 Report 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 !
bubu Posted February 18, 2005 Report 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
andrez Posted February 18, 2005 Author Report 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 :/
Klez Posted February 19, 2005 Report 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"
Recommended Posts