Jump to content

[SOLVED] Selecting the last character of a variable


almightyegg

Recommended Posts

Hmmm a few ways to do this....

 

Here are the first two that come to mind....  Not sure which is faster, but it's probably the first.

 

$word = 'thomas';
$s = $word[strlen($word)-1];

$word = 'thomas';
$l = strlen($word);
$s = sub_str($word, $l-2, $l-1);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.