How do I strip the last line from a string. I have a string in CSV format and I want to get rid of the last string. Am I going to have to split the string into an array and then reconstruct it or is there a quicker way? Thanx Rob
I think the array will be the only sensible way to go - sorry
if $mystr contains the CSV file
$pos = strrpos($mystr, "\n"); //get the last occurrence of 'newline' $mystr = substr($mystr, 0, $pos);
Your file shouldn't teminate with a "\n", if this is the case just perform the process twice
ciao, *M
Thanks Guys, I'm really going to have to get into the habit of thinking before I post. I solved it with this
$bib_string=strrev(substr(strrev($bib_string),strpos(strrev($bib_string),"\n")));
Thanks Guys Rob
PS. Although I think I'm actually going to use the one you wrote webcase. It looks a lot tidier than mine.