3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array( "service" => "coding", "data" => array( "ITEM" => array( array( "CODE" => "9999", //STANDARD "QUANTITY" => 1 ), ) ) ); $array2 = array( array( "a" => "1", "b" => "1", "c" => "1", "d" => "1", ), array( "cancel" => "1", "a" => "1", "b" => "", "c" => "", "d" => "1", ), array( "cancel" => "1", "a" => "", "b" => "1", "c" => "1", "d" => "", ), ); foreach ($array2 as $i => ['a' => $a, 'c' => $c]) { $temp = $array1; if($a == 1) { $temp['data']['ITEM'][] = [ 'SOMETHING' => 'this_is_a', 'ELSE' => '1' ]; } if ($c == 1) { $temp['data']['ITEM'][] = [ 'SOMETHING' => 'this_is_c', 'ELSE' => '1' ]; } echo "Loop #$i result:\n"; var_export($temp); echo "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Loop #0 result: array ( 'service' => 'coding', 'data' => array ( 'ITEM' => array ( 0 => array ( 'CODE' => '9999', 'QUANTITY' => 1, ), 1 => array ( 'SOMETHING' => 'this_is_a', 'ELSE' => '1', ), 2 => array ( 'SOMETHING' => 'this_is_c', 'ELSE' => '1', ), ), ), ) Loop #1 result: array ( 'service' => 'coding', 'data' => array ( 'ITEM' => array ( 0 => array ( 'CODE' => '9999', 'QUANTITY' => 1, ), 1 => array ( 'SOMETHING' => 'this_is_a', 'ELSE' => '1', ), ), ), ) Loop #2 result: array ( 'service' => 'coding', 'data' => array ( 'ITEM' => array ( 0 => array ( 'CODE' => '9999', 'QUANTITY' => 1, ), 1 => array ( 'SOMETHING' => 'this_is_c', 'ELSE' => '1', ), ), ), )

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:
29.13 ms | 403 KiB | 8 Q