3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combineColumns(array $row, $separator) // {{{ { $combined = array(); foreach ($row as $key => $value) { if (false !== strpos($key, $separator)) { $parts = explode($separator, $key); $pkey = array_pop($parts); $ptr = &$combined; while (null !== ($part = array_shift($parts))) { if (!isset($ptr[$part]) || !is_array($ptr[$part])) { $ptr[$part] = array(); } $ptr = &$ptr[$part]; } $ptr[$pkey] = $value; } else { $combined[$key] = $value; } } } print_r(combineColumns(array( 'A' => 1, 'B_C' => 2, 'B_D_A' => 3, 'D_K_F' => 4, ), '__'));
Output for git.master, git.master_jit, rfc.property-hooks

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