Simple way to remove last character from a String in PHP


Are you looking for a one line script that will remove the last character of a String?.
Is your question is how to remove the last Character of a String using PHP?.

Here is the Answer for you:

Its very simple you can achieve with the PHP function called substr();

Here is the script:


//see the below string with one extra ?

$string = "simple and easy script you know?? ";

//remove with the help of substr();

echo  substr($string, 0, -1);



simple and easy script you know?

I hope this script might help you in a critical situation!!.

Leave a Reply

Theme: Overlay by Kaira