Page 1 of 1

Skip one line?

Posted: Wed Apr 15, 2009 2:10 pm
by Burton333
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


I'm trying to get the file into array strings, but then I just want to ignore/delete the first line which are the fields. Can someone help me?

Code: Select all

<?php
$lines = file('http://giraffe.uvm.edu/~rgweb/batch/curr_enroll_fall.txt');
 
// Loop through array
foreach ($lines as $line_num => $line) {
    echo $line . "<br />\n";
}
?>
My overall objective though is to use the information below the first line. I want to then split each thing using the split() function, and then place each variable accordingly into the database. Having this file consistently refresh in order to get the most accurate current information. Can someone please lead me in the right direction?


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Skip one line?

Posted: Wed Apr 15, 2009 2:54 pm
by pickle
array_shift() will get rid of the first row for you.

If this is a comma separated file, or some other format delimited by a common character, consider explode() instead of split(). Anything that uses regular expressions is costly (in terms of processor cycles) and should be avoided if at all possible.

Re: Skip one line?

Posted: Wed Apr 15, 2009 3:12 pm
by McInfo
If you need the first line to remain in the array, use continue.

Edit: This post was recovered from search engine cache.