I need to delete the first 3 letters of a string and the last 3 letters of a string. I know I can use substr() to start at a certain character but if I need to strip both fi
As stated in other answers you can use one of the following functions to reach your goal:
It depends on the amount of chars you need to remove and if the removal needs to be specific. But finally substr() answers your question perfectly.
Maybe someone thinks about removing the first/last char through string dereferencing. Forget that, it will not work as null is a char as well:
returns:
string(13) "Stackoverflow"
string(13) "tackoverflow"
string(13) "tackoverflow"
0
string(13) "ackoverflow"
0
And it is not possible to use unset($string[0]) for strings:
Fatal error: Cannot unset string offsets in /usr/www/***.php on line **