Dubz
11-22-2011, 02:51 AM
I'm wondering how you can grab the last character of a string.
For example:
$string = "The quick brown fox jumps over the lazy dog";
echo $string{0};
//Echoes the letter T
echo $string{5};
//Echoes the letter u
My question is, how can you get the LAST character of the string without knowing its length? I tried using -1 but ad no luck (unless it was in another part that it came out wrong). If their isn't another way I could always use strlength and get it but I'm just wondering if theirs an actual way for this
For example:
$string = "The quick brown fox jumps over the lazy dog";
echo $string{0};
//Echoes the letter T
echo $string{5};
//Echoes the letter u
My question is, how can you get the LAST character of the string without knowing its length? I tried using -1 but ad no luck (unless it was in another part that it came out wrong). If their isn't another way I could always use strlength and get it but I'm just wondering if theirs an actual way for this