3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ [ "id"=>"3", "weight"=>"20", "percentage"=>"80", ], [ "id"=>"1", "weight"=>"50", "percentage"=>"80", ], [ "id"=>"2", "weight"=>"40", "percentage"=>"80", ] ]; $arr2 = [ [ "id"=>"1", "stock"=>"9539.00" ], [ "id"=>"2", "stock"=>"9468.00" ], [ "id"=>"3", "stock"=>"9295.00" ] ]; $keys = array_flip(array_column($arr2, 'id')); $newArr = array_map(function($item) use($keys, $arr2){ $item['stock'] = $arr2[$keys[$item['id']]]['stock']; return $item; }, $arr1); var_dump($newArr);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(4) { ["id"]=> string(1) "3" ["weight"]=> string(2) "20" ["percentage"]=> string(2) "80" ["stock"]=> string(7) "9295.00" } [1]=> array(4) { ["id"]=> string(1) "1" ["weight"]=> string(2) "50" ["percentage"]=> string(2) "80" ["stock"]=> string(7) "9539.00" } [2]=> array(4) { ["id"]=> string(1) "2" ["weight"]=> string(2) "40" ["percentage"]=> string(2) "80" ["stock"]=> string(7) "9468.00" } }

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:
61.8 ms | 402 KiB | 8 Q