3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = <<<REGEX / #starting pattern delimiter (?> #starting atomic group, intended for performance ( #capture group 1 \[ #literal opening square brace (?: #non-capturing group for logic encapsulation (?> #starting atomic group, intended for performance [^[\]]+ #negate character class to match one or more non-square brace characters ) #closing atomic group | #or (?1) #recurse the subpattern contained within the first capture group )* #close non-capturing group and allow it to be repeated zero or more times \] #literal closing square brace ) #close capture group 1 | #or [^,[\]]+ #negate character class to match one or more non-square brace characters and non-commas )+ #close atomic group and require one or more matches of internal logic \K #forget previously matched characters to prevent losing them during splitting ,? #optionally match a comma /x REGEX; /* (cannot comment after pattern end) x modifier enables inline regex commenting */ var_export( preg_split( $regex, /* '/(?>(\[(?:(?>[^[\]]+)|(?1))*\])|[^,[\]]+)+\K,?/', */ "first,second[,b],third[a,b[1,2,3]],fourth[a[1,2]],sixth", 0, PREG_SPLIT_NO_EMPTY ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 'first', 1 => 'second[,b]', 2 => 'third[a,b[1,2,3]]', 3 => 'fourth[a[1,2]]', 4 => 'sixth', )

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:
85.83 ms | 405 KiB | 5 Q