3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = []; $i = 0; while($i < 2){ $ar['fluits'][$i][] = [ 'name' => 'apple', 'color' => 'red' ]; $ar['fluits'][$i][] = [ 'name' => 'kiwi', 'color' => 'green' ]; $ar['drinks'][$i][] = [ 'name' => 'coffee', 'taste' => 'bitter' ]; // これだと「apple」の配列には「2」が追加されるが、kiwiの配列に「2」が追加されない。 $add = 'on'; if( $add == 'on' ){ $ar['drinks'][$i][0]['id'] = '1'; $ar['fluits'][$i][0]['id'] = '2'; } $i++; } var_dump($ar);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["fluits"]=> array(2) { [0]=> array(2) { [0]=> array(3) { ["name"]=> string(5) "apple" ["color"]=> string(3) "red" ["id"]=> string(1) "2" } [1]=> array(2) { ["name"]=> string(4) "kiwi" ["color"]=> string(5) "green" } } [1]=> array(2) { [0]=> array(3) { ["name"]=> string(5) "apple" ["color"]=> string(3) "red" ["id"]=> string(1) "2" } [1]=> array(2) { ["name"]=> string(4) "kiwi" ["color"]=> string(5) "green" } } } ["drinks"]=> array(2) { [0]=> array(1) { [0]=> array(3) { ["name"]=> string(6) "coffee" ["taste"]=> string(6) "bitter" ["id"]=> string(1) "1" } } [1]=> array(1) { [0]=> array(3) { ["name"]=> string(6) "coffee" ["taste"]=> string(6) "bitter" ["id"]=> string(1) "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:
56.8 ms | 403 KiB | 8 Q