3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_make_square(array &$array, $fill = ' ') { $pad = count(array_keys($array)); foreach ($array as &$row) { $row = array_pad($row, $pad, $fill); } } function array_organize(array &$outer) { $offset = 0; foreach ($outer as &$inner) { sort($inner); array_rotate($inner, $offset++); } } function array_rotate(array &$array, $offset) { foreach (array_slice($array, 0, $offset, true) as $key => $val) { unset($array[$key]); $array[$key] = $val; } } function solve($test) { array_make_square($test); array_organize($test); return $test; } function display($outer) { echo "[\n"; foreach ($outer as $row => $inner) { echo " $row => ['" . implode("', '", $inner) . "']\n"; } echo "]\n"; } $tests = [ [ ['X'], ['X'], ['X'] ], [ ['X', 'Y'], ['X', 'Y'], ['X', 'Y'] ], [ ['X', 'Y', 'Z'], ['X', 'Y', 'Z'], ['X', 'Y', 'Z'] ], ]; array_map('display', array_map('solve', $tests));
Output for git.master, git.master_jit, rfc.property-hooks
[ 0 => [' ', ' ', 'X'] 1 => [' ', 'X', ' '] 2 => ['X', ' ', ' '] ] [ 0 => [' ', 'X', 'Y'] 1 => ['X', 'Y', ' '] 2 => ['Y', ' ', 'X'] ] [ 0 => ['X', 'Y', 'Z'] 1 => ['Y', 'Z', 'X'] 2 => ['Z', 'X', 'Y'] ]

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:
64.32 ms | 401 KiB | 8 Q