Advertisement
Guest User

TextAbr

a guest
Dec 19th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.     $list = $_GET['list'];
  3.     $maxSize = intval($_GET['maxSize']);
  4.     $newLine = preg_split('/\r\n/', $list, -1, PREG_SPLIT_NO_EMPTY);
  5.     echo "<ul>";
  6.     for ($i=0; $i < sizeof($newLine); $i++) {
  7.        
  8.         $result= trim($newLine[$i]);
  9.      
  10.         if (strlen($result) > $maxSize) {
  11.             $result = substr($result, 0, $maxSize);
  12.             echo '<li>' .  htmlspecialchars($result)  . '...' . '</li>';
  13.         } else {
  14.             if ($result != "") {
  15.                 $result = substr($result, 0, $maxSize);
  16.             echo '<li>' .  htmlspecialchars($result)  . '</li>';
  17.             }
  18.         }
  19.     }
  20.     echo "</ul>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement