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));
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => (1) This is a test. [1] => a) This is a subtest one. [2] => b) And another one. [3] => (2) A really cool test. [4] => (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. [5] => (4) How can I match the multi-line entries and unwrap them to single lines? [6] => (1) This is a test. [7] => a) This is a subtest one. [8] => b) And another one. [9] => (2) A really cool test. [10] => (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. [11] => (4) How can I match the multi-line entries and unwrap them to single lines? [12] => (1) This is a test. [13] => a) This is a subtest one. [14] => b) And another one. [15] => (2) A really cool test. [16] => (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. [17] => (4) How can I match the multi-line entries and unwrap them to single lines? [18] => a) dfk )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.99 ms | 1646 KiB | 4 Q