I have these 2 snippets of code that I have been playing with, but can\'t seem to get the logic to stick in either of them.
I am trying to see if a given string has
you can try to use this function
function endsWith($FullStr, $needle)
{
$StrLen = strlen($needle);
$FullStrEnd = substr($FullStr, strlen($FullStr) - $StrLen);
return $FullStrEnd == $needle;
}
taken from by blog post
then use it like
if (endsWith($path,'/') == false)
{
$path = $path."/";
}
and offcourse if you do not want to use above function to siplify things then you should change the way you are using substr
correct way to get last char is substr($path,-1)