3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reverseRecursive($array, $recursing = false) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = '(' . reverseRecursive($value, true) . ')'; } } $first = $recursing ? array_shift($array) . ',' : ''; return $first . implode(',', array_reverse($array)); } $data = '(X,1,1,3),(X,1,1,3),(X,@2,@2,@2,@2,@2,(Y,1))'; $json = preg_replace(['/[^(),]+/', '/\(/', '/\)/'], ['"$0"', '[', ']'], "($data)"); $inverse = reverseRecursive(json_decode($json)); echo $inverse;
Output for git.master_jit, git.master, rfc.property-hooks
(X,(Y,1),@2,@2,@2,@2,@2),(X,3,1,1),(X,3,1,1)

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