jam Posted July 24, 2005 Report Share Posted July 24, 2005 Man ir strings /fol1/fol2/fol3/ un vajag dabūt /fol1/fol2/ . Droši vien, ka easy, bet man rokas pa īsu, lai atrastu :/ Link to comment Share on other sites More sharing options...
Klez Posted July 24, 2005 Report Share Posted July 24, 2005 $str = '/fol1/fol2/fol3/ '; $sagr = explode('/', $str); print_r($sagr); /* echo $sagr[0]; //shis buus pirmais echo $sagr[1]; //shis buus otrais */ viens no variantiem , un tad skaties ko tew waig Link to comment Share on other sites More sharing options...
bubu Posted July 24, 2005 Report Share Posted July 24, 2005 (edited) Ir varianti: <?php $str = '/fol1/fol2/fol3/'; #1 variants echo implode('/', array_splice(explode('/', $str), 0, -2)).'/'; #2 variants if (preg_match('@^(.*/)[^/]+/$@', $str, $m)) { echo $m[1]; } #3 variants echo substr($str, 0, strrpos(substr($str, 0, -1), '/')+1); ?> Edited July 24, 2005 by bubu Link to comment Share on other sites More sharing options...
jam Posted July 24, 2005 Author Report Share Posted July 24, 2005 a var jau buut ta, ka tas urlis ir garaaks, tb ja ir /asdc/asdc/asd/ca/sdc/asd/ca/sdc/asdc/as/cd/a/asd/ tad vajag atgriezt bez peedeejaa /asd/. Link to comment Share on other sites More sharing options...
bubu Posted July 24, 2005 Report Share Posted July 24, 2005 Nu un tu manus piemērus nepamēģināji? Tie visi tieši to jau arī dara. Atmet tekstu pēc pirmspēdējā / Link to comment Share on other sites More sharing options...
jam Posted July 24, 2005 Author Report Share Posted July 24, 2005 Nu un tu manus piemērus nepamēģināji? Tie visi tieši to jau arī dara. Atmet tekstu pēc pirmspēdējā / 19802[/snapback] Oi, pardon, shancee ideali! Link to comment Share on other sites More sharing options...
Recommended Posts