Need help trimming text
Posted: Tue May 24, 2005 4:29 pm
I'm working on some PHP code and I am creating a system where text is read line by line from a file and adds it to a list in alternating lines so the odd lines are the title and even lines are the content:
It seems to work except I need to trim the line delimiters from the end, can anyone suggest a simple way of doing this? (I'm a bit of a numpty here)
Code: Select all
$counter = 0;
foreach ($data as $line) {
if( $counter % 2 == 0 ) {
$field = $line;
}
else {
$this->sitedata[$field] = $line;
}
$counter++;
}