Php: How to remove last 3 characters from a string
To remove the last three characters from a string, we can use the substr() function by passing the start and length as arguments.
Here is an example, that removes the last three characters from a given string.
$name="John res";
//if length is negative it starts removing from the end
$result = substr($name,0,-3);
echo $result;Output:
JohnThe substr() function doesn’t mutate the original string, instead of it creates a new string the modified data.


