Размер файла: 0.98Kb
- <?php
-
- /*
- * @function: Класс обрезки текста
- * @author: Shamsik
- * @$subclass->cutstring (Текст, Символы)
- */
-
- class substr {
-
-
- function cutstring( $stranb, $lengthanb, $theend="..." ) {
-
- if (strlen($stranb)>30) {$text2=substr($stranb, 0, $lengthanb);
-
- $words=explode(" ", $text2);
- $words=array_reverse($words);
- array_splice($words,0,1);
- $alexxnb=0;
- for ($i=0; $i<count($words); $i++) {
- $i=$i-$alexxnb;
- if (substr($words[$i], -1)=="," OR substr($words[$i], -1)=="." OR substr($words[$i], -1)==":" OR substr($words[$i], -1)==";") {
- $words[$i]=substr($words[$i],0, strlen($words[$i])-1);
- };
- $wrd=$words[$i];
- if (strlen($wrd)<4){
- array_splice($words,$i,1);$alexxnb=1;
- } else {
- $i=1985;
- };
- };
- $mwords="";
- $words=array_reverse($words);
- for ($i=0; $i<count($words); $i++) {
- $mwords=$mwords.$words[$i];
- if ($i!=count($words)-1) {$mwords=$mwords." ";} else {$mwords=$mwords.$theend;};
- };
- } else {$mwords=$stranb;};
- return $mwords;
- }
- }
-
- $subclass = new substr;
-
-
- ?>