Checking a String Character in PHP
Let there be a given string consisting of digits:
<?php
$str = '12345';
?>
Let's check if the first character
of this string is equal to the number 1:
<?php
$str = '12345';
if ($str[0] == 1) {
echo '!';
}
?>
Now let's check if the last character is equal
to the number 5:
<?php
$str = '12345';
$last = $str[-1];
if ($last == 5) {
echo '!';
}
?>
A certain string is given. Check
if it ends with '0'.