Advertisement
shmaltorhbooks

extract comments

Feb 8th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. $separator = '//';
  4. $file = '';
  5.  
  6. foreach ($argv as $argNum => $argVal) {
  7.     if ($argVal == '-file') {
  8.         $file = $argv[$argNum + 1];
  9.     }
  10.     if ($argVal == '-separator') {
  11.         $separator = $argv[$argNum + 1] . ' ';
  12.     }
  13. }
  14.  
  15. $content = file($file);
  16.  
  17.  
  18. $res = array();
  19. foreach ($content as $line) {
  20.     $line = trim($line);
  21.     if (false !== strpos($line, $separator)) {
  22.         $res[] = str_replace($separator, '', $line);
  23.     }
  24. }
  25.  
  26. $res = iconv('windows-1251', 'utf8', implode(PHP_EOL, $res));
  27. echo $res;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement