69 of 110 menu

The Last Character of a String in PHP

To get the last character of a string, you can use the substr function. See the example:

<?php $last = substr('abcdef', -1) echo $last; ?>

Code execution result:

'f'
English
БеларускаяEspañolРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline