I've got a problem here I know what I want to do but cant get around coding it, I've already opened a text document using my PHP code now I want to skip the first 59 lines of the document then send the first 4 strings of every sentence that follow after skipping those 59 lines to a database which I've already created. I've already written down the code that will skip that opens the document and skips the first 59 line now all I need to do is send the first 4 strings of every line to the database. Here is my code.
$url = 'C:\portsdocx.txt'; //my text document
$file = file_get_contents($url) //opens up my document
or die("Could Not Open The TEXT File<hr /> " . mysql_error());
$file = implode("\n", array_slice(explode("\n", $file), 59));// skips the first 59 lines
And the the code that says explode the first 4 strings of every line comes here which is what I really want!!! I know I should use the explode function but cant really figure out how.
And then the data gets sent to my database.
here's the code.
while ($data = file_get_contents($file, 10000))
{
mysql_query("INSERT into registry
('ServiceName','PortNumber','TransportProtocol','Description')
VALUES('".$data['0']."','".$data['1']."','".$data['2']."','".$data['3']."')");
}
Thanks in advance.