3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<'EOD' #1 (1) This is a test. a) This is a subtest one. b) And another one. (2) A really cool test. (3) Here is the problem, text for each numbered line is supposed to be on a single line like in (1) and (2), but the text often spans multiple lines of text. (4) How can I match the multi-line entries and unwrap them to single lines? #2 (1) This is a test. a) This is a subtest one. b) And another one. (2) A really cool test. (3) Here is the problem, text for each numbered line is supposed to be on a single line like in (1) and (2), but the text often spans multiple lines of text. (4) How can I match the multi-line entries and unwrap them to single lines? #3 (1) This is a test. a) This is a subtest one. b) And another one. (2) A really cool test. (3) Here is the problem, text for each numbered line is supposed to be on a single line like in (1) and (2), but the text often spans multiple lines of text. (4) How can I match the multi-line entries and unwrap them to single lines? a) dfk EOD; print_r(preg_split('~(\R+|^#\d+$)+(?=\(\d+\)|[a-z]\)|\z)~m', $str, -1, PREG_SPLIT_NO_EMPTY));

preferences:
84.78 ms | 1646 KiB | 5 Q