3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = Array ( 'id' => Array ( 0 => 1, 1 => 3 ), 'reward' => Array ( 0 => 'Movie', 1 => 'Trip' ), 'cost' => Array ( 0 => 50, 1 => 200 ) ); $output = array(); // Iterate the original array's [id] sub-array foreach ($original['id'] as $idxkey => $newkey) { // Add a sub-array using $newkey to the output array $output[$newkey] = array( // Using the index (not value), retrieve the corresponding reward // value to use as the new array key // and corresponding cost to use as the new subarray value $original['reward'][$idxkey] => $original['cost'][$idxkey] ); } print_r($output);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [1] => Array ( [Movie] => 50 ) [3] => Array ( [Trip] => 200 ) )

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