3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'NUM' => [ 101, 102, 103, ], 'NOM' => [ 'Smith', 'Robson', 'Daniels', ], 'PRENOM' => [ 'Alice', 'Bob', 'Charlie', ], ]; // Grab all possible outer keys $outerKeys = array_keys($data); // Make sure all child arrays are the same size $innerCount = null; foreach($outerKeys as $key) { // Also make sure that we've got a list so that we don't have to keep // track of child keys. For a 7.x polyfill see // https://www.php.net/manual/en/function.array-is-list.php if(!array_is_list($data[$key])){ throw new RuntimeException('Child array is not a list'); } // Count the first item if(null === $innerCount){ $innerCount = count($data[$key]); continue; } // Compare the known count with the current child array if($innerCount !== count($data[$key])){ throw new RuntimeException('Child array does not have equal item count'); } } $lines = []; for($idx = 0; $idx < $innerCount; $idx++){ $buf = []; foreach($outerKeys as $key){ $buf[] = $key . ':' . $data[$key][$idx]; } $lines[] = implode(' ', $buf); } echo implode(PHP_EOL, $lines);
Output for git.master, git.master_jit, rfc.property-hooks
NUM:101 NOM:Smith PRENOM:Alice NUM:102 NOM:Robson PRENOM:Bob NUM:103 NOM:Daniels PRENOM:Charlie

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