Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Get the Last Character of a String in PHP

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