Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function parseFile($filename, $column = null)
- {
- $f = file_get_contents($filename);
- $f = iconv("WINDOWS-1251", "UTF-8", $f);
- file_put_contents($filename . '.new', $f);
- $handle = fopen($filename . '.new', "r");
- $result = array();
- while (!feof($handle)) {
- $firms = fgetcsv($handle, 0, ";");
- while(count($firms) < $column && !feof($handle)) {
- $tmp = fgetcsv($handle, 0, ";");
- $tmp[0] = array_pop($firms) . $tmp[0];
- $firms = array_merge($firms, $tmp);
- }
- array_push($result, $firms);
- }
- return $result;
- }
- $filename = __DIR__ . '/Out/Firms.txt';
- echo var_dump(parseFile($filename, 15));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement