Advertisement
imedvedev

парсер

Mar 25th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?
  2. $arFile = array();
  3.  
  4. $handle = fopen("table.txt", "r");
  5. if ($handle) {
  6.     while (($line = fgets($handle)) !== false) {
  7.         $pattern = '/\d+/';
  8.         preg_match_all($pattern, $line, $matches);
  9.  
  10.         unset($matches[0][0]);
  11.         $arFile[] = $matches[0];
  12.     }
  13.  
  14.     fclose($handle);
  15. } else {
  16.     // ошибка открытия файла
  17. }
  18.  
  19. file_put_contents("table.php", '<? $arTable = ' . var_export($arFile, true) . ';');
  20. // сохраняем в table.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement