When making statistical charts, you need to use "," to separate the data when fetching it. However, when I use a loop to accumulate strings, it is inevitable that there will be an extra "," in the end. For example, I took out 1,2,3,4,5, but I need to delete the comma at the end of the string to get 1,2,3,4,5.
When making statistical charts, you need to separate the data with "," when extracting it. However, when I use a loop to accumulate strings, it is inevitable that there will be an extra "," in the end. For example, I took out 1,2,3,4,5, but I need to delete the comma at the end of the string to get 1,2,3,4,5. Solution: Using php’s substr method, Syntax: string substr(string string, int start, int [length]); Parameter 1: original string; Parameter 2: starting position of cutting; Parameter 3: intercepted length; Use it like this: $newstr = substr($str,0,strlen($str)-1); Cut from the beginning to the penultimate digit, thus removing the last ",". |