3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ["item_id" => "1", "item_name" => "a"], ["item_id" => "2", "item_name" => "b"], ["item_id" => "3", "item_name" => "c"], ["item_id" => "4", "item_name" => "d"], ["item_id" => "5", "item_name" => "e"], ["item_id" => "6", "item_name" => "f"] ]; $val = [10, 11, 12]; $bump = count($array) - count($val); foreach ($val as $i => $number) { $array[$i + $bump]['value'] = $number; } var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'item_id' => '1', 'item_name' => 'a', ), 1 => array ( 'item_id' => '2', 'item_name' => 'b', ), 2 => array ( 'item_id' => '3', 'item_name' => 'c', ), 3 => array ( 'item_id' => '4', 'item_name' => 'd', 'value' => 10, ), 4 => array ( 'item_id' => '5', 'item_name' => 'e', 'value' => 11, ), 5 => array ( 'item_id' => '6', 'item_name' => 'f', 'value' => 12, ), )

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:
53.92 ms | 1469 KiB | 4 Q