kechums Posted February 22, 2008 Report Share Posted February 22, 2008 (edited) Sveicināti! Meklēju pavisam vienkāršu skriptu, kas ierobežo simbolu skaitu, teiksim, es gribu, lai maksimālais, ko rādītu ir 8 burti vai simboli un, ja ir vairāk par 8 simboliem, tad tālāk seko daudzpunkte. Atvainojos, ja šāds topiks jau te ir bijis, bet neatradu īsti kaut ko līdzīgu šim. Googlē arī meklēju, bet neko tieši tam, ko vajag man neizdevās izvilkt. Ceru uz palīdzību! Edited February 22, 2008 by kechums Link to comment Share on other sites More sharing options...
andrisp Posted February 22, 2008 Report Share Posted February 22, 2008 if (strlen($str) > 8) { $str = substr($str, 0, 8).'...'; } Link to comment Share on other sites More sharing options...
bubu Posted February 22, 2008 Report Share Posted February 22, 2008 if ($teksta garums > 8) { $teksts = pirmie8simboli . "..."; } Un vajadzīgās funkcijas: http://php.net/strlen un http://php.net/substr Link to comment Share on other sites More sharing options...
kechums Posted February 22, 2008 Author Report Share Posted February 22, 2008 Paldies par palīdzību! Link to comment Share on other sites More sharing options...
blackhalt Posted February 23, 2008 Report Share Posted February 23, 2008 http://lv.php.net/manual/en/function.substr.php#78019 Link to comment Share on other sites More sharing options...
Paulinjsh Posted February 24, 2008 Report Share Posted February 24, 2008 ar utf8 būs prolēmas - iesaku labāk lietot atbilstošās mb funkcijas http://lv.php.net/mb_strlen un http://lv.php.net/mb_substr Link to comment Share on other sites More sharing options...
Recommended Posts