3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "{tab=Text1} <p> nejaky</p><p>dlouhy text 1</p> ... {tab=Text2} <p>Jiny text...{test}.</p> {tab=Text3} .... {/tab} {tab=Text4} <p> nejaky</p><p>dlouhy text 1</p> ... "; $pattern="/(?:{tab=(?P<tab>[^}]+)})\n(?P<content>(?:(?!\n{\/?tab[^}]*}).)*)/s"; preg_match_all($pattern, $text, $matches); $result = []; if($matches) foreach($matches["tab"] as $i => $name) { if(isset($result[$name])) throw new Exception("Duplicate tab name '{$name}'"); $result[$name] = $matches["content"][$i]; } var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { ["Text1"]=> string(40) "<p> nejaky</p><p>dlouhy text 1</p> ... " ["Text2"]=> string(28) "<p>Jiny text...{test}.</p> " ["Text3"]=> string(4) "...." ["Text4"]=> string(41) "<p> nejaky</p><p>dlouhy text 1</p> ... " }

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