Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $ip = file_get_contents($path);
  2. $ip = explode("\n", normalize($ip));
  3. foreach($ip as $entry)
  4. {
  5. if(!$entry)
  6. continue;
  7.  
  8. echo '<tr>';
  9. echo '<td class="IP">' . $entry . '</td>';
  10. echo '<td class="jmeno">N/A</td>';
  11. echo '</tr>';
  12. }
  13.  
  14.  
  15. function normalize($s)
  16. {
  17. // standardize line endings to unix-like
  18. $s = str_replace("\r\n", "\n", $s); // DOS
  19. $s = strtr($s, "\r", "\n"); // Mac
  20.  
  21. // remove control characters; leave \t + \n
  22. $s = preg_replace('#[\x00-\x08\x0B-\x1F\x7F]+#', '', $s);
  23.  
  24. // right trim
  25. $s = preg_replace("#[\t ]+$#m", '', $s);
  26.  
  27. // trailing spaces
  28. $s = trim($s, "\n");
  29.  
  30. return $s;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement