PHP Using Negative Lengths Allows You To Say “Copy Everything But Last Three Characters,” – String Function

<?
    $string = "Goodbye, Perl!"
    $a = substr($string, 5);    $b = substr($string, 5, 5);    $c = substr($string, 0, -1);    $d = substr($string, -5);    $e = substr($string, -5, 4);    $e will be set to "Perl"    $f = substr($string, -5, -4);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.