I have a php script that truncates a string of 41 bytes. I call strlen on a string to check its size. However, if the line has the command "\ r \ n", this combo is considered as one byte. Therefore, in my case, instead of 42 bytes, PHP considers it to be 41 bytes.
Also substr truncates it to 42 instead of 41 bytes.
if (strlen($value) > 41) { $value = substr($value, 0, 41);
Another strange condition. I have a large dataset that I go through this function. Thousands of lines. If I use a simpler set of test data, then the code works correctly, treating "\ r \ n" as 2 bytes.
Any ideas? Thanks.
jriggs
source share