3v4l.org

run code in 300+ PHP versions simultaneously
<?php $comment = " some text {Varinat #3 smth} {Varinat #4 smth else} {Varinat #1 smth else 1} some another text {Varinat #2 smth else 2} {Varinat #5 smth else 5} "; $lines = explode("\n",$comment); $processed = array_map(function($line) { if( preg_match('(^\{Varinat #(\d+))', $line, $match)) { return [$line,$match[1]]; } return [$line,null]; }, $lines); $variant = array_filter($processed,function($data) {return $data[1];}); usort($variant,function($a,$b) {return $a[1] - $b[1];}); $sorted = array_map(function($data) use (&$variant) { if( $data[1]) return array_shift($variant)[0]; else return $data[0]; },$processed); $result = implode("\n",$sorted); echo $result;
Output for git.master_jit, git.master, rfc.property-hooks
some text {Varinat #1 smth else 1} {Varinat #2 smth else 2} {Varinat #3 smth} some another text {Varinat #4 smth else} {Varinat #5 smth else 5}

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