bubu Posted April 21, 2007 Report Share Posted April 21, 2007 Kā kur lai meklē? Pats piemēram ņem un uzraksti. Ja strings garāks par N burtiem, tad nogriez no sākuma X burtus, no beigām Y burtus un saliec abus kopā atdalītus ar "...". Nav nemaz tik grūti. Link to comment Share on other sites More sharing options...
aldis Posted April 21, 2007 Report Share Posted April 21, 2007 mekleet var uzraxtot googlee tutorials, vai php.net vai palasot te kaadu vecaaku postu... man skiet k-ks shitads te bija! Link to comment Share on other sites More sharing options...
dmitriy Posted April 21, 2007 Report Share Posted April 21, 2007 (edited) echo ((strlen($item) > 15) ? substr($item, 0, ((int)(strlen($item)-10)/2)).'...'.substr($item, ((int)(strlen($item)-10)/2+5)) : $item).'<br/>'; laikam sitais te tev ir vajadzigs, sorry ka viena linija. Edited April 21, 2007 by dmitriy Link to comment Share on other sites More sharing options...
bubu Posted April 21, 2007 Report Share Posted April 21, 2007 dmitriy: un kas būs, ja $item saturēs 100 simbolus? Liela jēga no 10 simbolu izgriešanas no vidus gan nebūs. Vajag jau griezt no vidus ārā strlen($item)-2*X simbolus, kur X ir tik cik gribi lai paliek abos galos (t.i atstāt katrā malā pa X simboliem). Link to comment Share on other sites More sharing options...
dmitriy Posted April 22, 2007 Report Share Posted April 22, 2007 ja, mana kluda Link to comment Share on other sites More sharing options...
andrisp Posted April 22, 2007 Report Share Posted April 22, 2007 if (strlen($str) > 15) { $str = substr($str,0,6).'...'.substr($str,-6,6); } Link to comment Share on other sites More sharing options...
Paulinjsh Posted April 22, 2007 Report Share Posted April 22, 2007 mb_substr Link to comment Share on other sites More sharing options...
Recommended Posts