How can I remove 3 characters at the end of a string in php?
Just do:
echo substr($string, 0, -3);
You don't need to use a strlen
call, since, as noted in the substr docs:
If length is given and is negative, then that many characters will be omitted from the end of string
<?php echo substr("abcabcabc", 0, -3); ?>
<?php echo substr($string, 0, strlen($string) - 3); ?>