- // Strip the trailing \n. The last line of a file might not have a trailing
- // \n though
- if ( $data[ strlen( $data ) - 1 ] == "\n" ) {
+ if ( substr( $data, - 1 ) === "\n" ) {
+ // Strip any final new line used to delimit lines of input.
+ // The last line of input might not have it, though.