'\n' // second substitution '\n' -> PHP_EOL // remove any EOL at the EOF return rtrim(str_replace(["\r\n", "\n"], ["\n", PHP_EOL], $content), PHP_EOL); } }