Advertisement
milen_vm

1.TextAbbreviator

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