Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $file_handle = fopen('fixy.txt', 'r');
- while ($line = fgets($file_handle)) {
- $output[] = array(
- 'title' => trim(substr($line, 0, 50)),
- 'code' => trim(substr($line, 50, 5)),
- 'date' => trim(substr($line, 55, 8)),
- 'writer' => trim(substr($line, 63, 50))
- );
- }
- fclose($file_handle);
- $information['type1'] = array(
- array('name' => 'title', 'position' => 0, 'length' => 50),
- array('name' => 'code', 'position' => 50, 'length' => 5),
- array('name' => 'date', 'position' => 55, 'length' => 8),
- array('name' => 'writer', 'position' => 63, 'length' => 50)
- );
- //there will also be a type 2, 3 and so on...
- $type = $information['type1'];
- ...
- while ($line = fgets($file_handle)) {
- ...
- $type['name'] => trim(substr($line, $type['position'], $type['length'])),...
- ...
- }
- $information['type1'] = array(
- array('name' => 'title', 'position' => 0, 'length' => 50),
- array('name' => 'code', 'position' => 50, 'length' => 5),
- array('name' => 'date', 'position' => 55, 'length' => 8),
- array('name' => 'writer', 'position' => 63, 'length' => 50)
- );
- $type = $information['type1'];
- $file_handle = fopen('fixy.txt', 'r');
- while ($line = fgets($file_handle))
- {
- $output[$type['name']] = trim(substr($line, $type['position'], $type['length']));
- }
- fclose($file_handle);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement