in reply to Re: Efficienty truncating a long string
in thread Efficienty truncating a long string
Note that length($buffer) is bigger than the actual length(buffer)-$end-1 you want, but specifying a length larger than is available is guaranteed to not cause problems; you'll just get what is there. If the buffer ends with "\n", you'll get an empty $fragment.$end = rindex($buffer, "\n"); if ($end < 0) { whoops, incomplete line } $fragment = substr($buffer, $end+1, length($buffer), '');
|
|---|