Substring to take all letters after the 4th character
I only have a basic understanding of substring. I am trying to extract the first 4 characters as a string variable and extract the rest of the characters in another string variable. How may I do this with substring? With PHP
$rest = substr("jKsuSposdfsdfsdrtTopics", -3, 1);
$rest2 = substr("jKsuSportsdffdsTopics", 4, 0);
1Answer
The second argument is the starting index, and the third argument is the length of the string. If the 3rd argument is missing, you'll get the rest of the string.
$rest = substr("jKsuSposdfsdfsdrtTopics", 0, 4);
$rest2 = substr("jKsuSportsdffdsTopics", 4);
- answered 8 years ago
- Community wiki
Your Answer