Click to See Complete Forum and Search --> : [RESOLVED] What's wrong with this?


hex1a4
01-16-2008, 09:24 AM
Hi,

All I want to do is check if the last character of a string is a forward slash ('/') and based on the result assign a value to a variable. This is how I'm doing it:
$n=(substr($row[url],0,strlen($row[url])-1)=="/") ? 8 : 7;
For URLs with a trailing slash $n should be 8, but regardless of whether or not the URL has a trailing forward slash $n is always 7. Why is that?

Lubox
01-16-2008, 09:38 AM
$n=(substr($row[url],-1)=="/") ? 8 : 7;

should work?

Lubox

hex1a4
01-16-2008, 09:56 AM
should work?

It does. Thank you very much.