finding lines ending in ")" with substr()
Posted: Fri Apr 24, 2009 12:29 pm
I'm running into an odd situation using substr(). I am trying to find all lines in a text file that end in a ")" or more accurately ")\n" using substr(). First I read in a line and then explode it into an array called $words. Then when I try
This returns all lines in the file as expected. But when I try
or
It returns none of the lines and I'm not seeing why. I've tried several similar combinations all with no luck. Can anyone spot what I am doing wrong? Thanks! -adam
Code: Select all
if(substr($words[count($words) -1], -1) == "\n")
{...}
Code: Select all
if(substr($words[count($words) -1], -2) == ")\n")
Code: Select all
if(substr($words[count($words) -1], -2, 1) == ")")