Jump to content

Skipping Lines and Text Files


HarryMW

Recommended Posts

Hello there,

 

I am currently trying to code something for a lil' project I have been hood-winked in to and I could do with some help, probably silly things but it's driving me nutty.

 

Firstly I need to connect to a text file which is online. So it won't be in a local directory but actually online and being updated whenever it is called.

 

Secondly, I need to separate skip out the lines that start with the character ";", and also try to separate the different parts of the text file with headers that start with "!GENERAL", for example.

 

There will be hundreds of entries so the results will need to be paginated obviously by 50 per page or something, if that's possible, hope so.

 

Oh and the lines will have about 30 different pieces of information that will need to be inputted into a db and updated if the information is older that whats currently in the db. All of the sets of data are separated by this character ":".

 

Any help will be appreciate, send me an e-mail on my address in my profile if you fancy giving me a quick hand at some point, thanks in advance.

 

Harry.

Link to comment
Share on other sites

I'm not nearly as good with REGEX as some of the REGEX ninjas on here, but this worked for me when trying to remove the semicolon lines:

 

$ptn = "/[^;](?:.*)\n/";
preg_match_all($ptn, $str, $match);

foreach($match[0] as $key => $value){
    echo "$value <br />"; // do whatever you want with the lines that don't start with ;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.