3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ [ "forename" => "Dave", "surname" => "Wood", "dob" => "23/05/1986", "gender" => "Male", ], ]; function outputr(array $input) { // work out the max length for each field $lengths = []; foreach ($input as $row) { foreach ($row as $key => $value) { if (!isset($lengths[$key])) { $lengths[$key] = 0; } $kl = strlen($key); $vl = strlen($value); $ln = ($kl > $vl) ? $kl : $vl; if ($ln > $lengths[$key]) { $lengths[$key] = $ln; } } } // output the table headers foreach ($lengths as $key => $length) { echo "+" . str_repeat("-", $length + 2); } echo "+\n"; foreach ($lengths as $key => $length) { $pad = $length - strlen($key); echo "| {$key} " . str_repeat(" ", $pad); } echo "|\n"; foreach ($lengths as $key => $length) { echo "+" . str_repeat("-", $length + 2); } echo "+\n"; } outputr($input);
Output for git.master, git.master_jit, rfc.property-hooks
+----------+---------+------------+--------+ | forename | surname | dob | gender | +----------+---------+------------+--------+

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