Answers for "php get string after last char"

PHP
24

php remove last char from string

//Remove the last character using substr
$string = substr($string, 0, -1);
Posted by: Guest on April-02-2020
0

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.";
?>
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language