Php: How to remove last 3 characters from a string
In this post we will give you information about Php: How to remove last 3 characters from a string. Hear we will give you detail about Php: How to remove last 3 characters from a stringAnd how to use it also give you demo for it if it is necessary.
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:
John
The substr() function doesn’t mutate the original string, instead of it creates a new string the modified data.
Hope this code and post will helped you for implement Php: How to remove last 3 characters from a string. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
