3v4l.org

run code in 300+ PHP versions simultaneously
<?php $frontendData = [ 'datasheet' => [ 'Name_1_balance0' => 1, // Data block 1 'Name_1_balance2' => 3, // Data block 1 'Name_1_balance13' => 4, // Data block 1 'Name_1_balance1' => 2, // Data block 1 'Name_2_balance0' => 5, // Data block 2 'Name_2_balance2' => 7, // Data block 2 'Name_2_balance3' => 8, // Data block 2 'Name_2_balance1' => 6, // Data block 2 ] ]; uksort($frontendData['datasheet'], 'strnatcmp'); $result = array(); foreach ($frontendData['datasheet'] as $key => $balance) { preg_match('/^(\w+)_balance(\d+)$/', $key, $match); $result[$match[1]][0] = $match[1]; $result[$match[1]][1]['balance'][$match[2]] = $balance; } $result = array('datasheet' => array_values($result)); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [datasheet] => Array ( [0] => Array ( [0] => Name_1 [1] => Array ( [balance] => Array ( [0] => 1 [1] => 2 [2] => 3 [13] => 4 ) ) ) [1] => Array ( [0] => Name_2 [1] => Array ( [balance] => Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 ) ) ) ) )

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:
26.85 ms | 409 KiB | 5 Q