"Organizing" txt file contents

Hi there,
I am new to this site so hopefully I am in the right place.

What I am trying to do is to get the contents of a file, such as text.txt, and write those contents into an array or preferably an XML file. But here’s the catch, content on the txt file will run from a certain line (ex line 16-160), everything else is irrelevant. I have looked into the file_get_contents() and fgetcsv() but so far no luck.

This is an example of the data I’m looking to pull from the txt file.

Thank you in advance.

if you want with an array , you can do this way (with or without explode)

[php]
$file = fopen(‘file.txt’,‘rb’);
for($i=0;$i<160;$i++)
{
$content = fgets($file);
if($i < 15)
continue;
$data = explode(" ",$content);
}
[/php]

if you want whole line as an array
[php]
$file = fopen(‘file.txt’,‘rb’);
for($i=0;$i<160;$i++)
{
$content = fgets($file);
if($i < 15)
continue;
$array[] = $content;
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service