Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Get the Last Character of a String in PHP

phpCopy<?php  
$string = "This is a string";
$lengthOfString = strlen($string);
$lastCharPosition = $lengthOfString-1;
$lastChar = $string[$lastCharPosition];
echo "The last char of the string is $lastChar.";
?>
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #Get #Last #Character #String #PHP
ADD COMMENT
Topic
Name
4+7 =