How to Remove Last Two Characters from String in PHP?

Hello Friends Today, through this tutorial, I will tell you how to Remove Last Two Characters from String with the help of php.

<?php
$string = "abcdefgh";
echo substr($string, 0, -2);
?>

As you have been told by the example above. If you want to run this code on the server, then you will first have to create a php file. And then add the above code to the php file. Then go to your server and run your file.

<?php 
$two_string = "zyxwvu"; 
echo substr($two_string, 0, -2); 
?>