If you pass substr() a negative number, it counts from the end of the string. : substr « String « PHP
- PHP
- String
- substr
If you pass substr() a negative number, it counts from the end of the string.
<?php
$test = "this is a test.";
if ( $test = substr( $test, -3 ) == "est") {
print "est";
} else {
print "Welcome to our shop!";
}
?>
Related examples in the same category