3v4l.org

run code in 300+ PHP versions simultaneously
<?php $depth = 0; $traverse = [0, 0, 0]; $tags = ['table', 'row', 'cell']; $regex = []; foreach ($tags as $key=>$tag) $regex[$key] = '/(\['.$tag.'((?:[\s\.\#]+[a-z]*)*)\]+[^\[]((?:.|\s)*?(?=(?:\['.$tag.')|$)))/'; echo var_export($tags),PHP_EOL; echo var_export($regex),PHP_EOL; $content = "[table] [row] [cell] [cell] [row] [cell] [cell] [table] [row] [row] [cell] [row] "; $f_parse = function($matches) use (&$depth, &$traverse, $tags, $regex, &$f_parse) { $traverse[++$depth]++; if ($depth < count($regex)) { preg_replace_callback( $regex[$depth], $f_parse, $matches[0] ); } /* echo "$depth | ${traverse[$depth]} | $tags, ${regex[$depth]}", PHP_EOL; $result = ""; if ($depth < count($regex)) { preg_replace_callback( $regex[$depth], $f_parse, $matches[0] ); } return $result;*/ echo $depth, ' | ', $traverse[$depth], ' | ', PHP_EOL; $traverse[$depth--]--; return $depth; }; $content = preg_replace_callback( $regex[$depth], $f_parse, $content ); echo $content, "\n"; ?>
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 'table', 1 => 'row', 2 => 'cell', ) array ( 0 => '/(\\[table((?:[\\s\\.\\#]+[a-z]*)*)\\]+[^\\[]((?:.|\\s)*?(?=(?:\\[table)|$)))/', 1 => '/(\\[row((?:[\\s\\.\\#]+[a-z]*)*)\\]+[^\\[]((?:.|\\s)*?(?=(?:\\[row)|$)))/', 2 => '/(\\[cell((?:[\\s\\.\\#]+[a-z]*)*)\\]+[^\\[]((?:.|\\s)*?(?=(?:\\[cell)|$)))/', ) Warning: Undefined array key 3 in /in/KnMrE on line 27 3 | 1 | 3 | 1 | 2 | 1 | 3 | 1 | 2 | 1 | 1 | 1 | 2 | 1 | 3 | 1 | 2 | 1 | 1 | 1 | 00

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:
79.65 ms | 402 KiB | 8 Q