How to remove the last few characters in php – PHP problem

The implementation method of php to remove the last few characters: first create a PHP example file; then define a string; finally, remove the last specified character by the “substr($str,0,-4);” method.

The implementation method of php to remove the last few characters: first create a PHP example file; then define a string; finally, remove the last specified character by the “substr($str,0,-4);” method.

Recommended: “PHP Video Tutorial”

<!--?php 
$str=&#39;programming&#39;; 
//Define a string 
$res=substr($str,-4); 
//Process string 
echo "return {$str} 
string The last 4 characters of {$res}"; 
$res=substr($str,0,-4); 
//Process the string 
echo "<br /-->Return the {$str} 
string with the last 4 characters removed {$res}";?>

Leave a Reply

Your email address will not be published.

en_USEnglish