<?php $inputs = [ 'Windows' => "Dog\r\nCat\r\nMouse", 'Linux' => "Bicycle\nCar\nTrain\nAirplane", 'Mac' => "iPhone\riPod\rMacBook", 'Win + Linux' => "int main() {\n return 0;\r\n}\n", 'All mixed up' => "This is a Windows new line\r\n, followed by a Linux new line\n and finally an old Mac with a single carriage return\rat the end", ]; foreach ($inputs as $env => $input) { preg_match_all('/\R/', $input, $matches); var_dump( $env, json_encode($matches[0]) ); }
You have javascript disabled. You will not be able to edit any code.