3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasColor(Array $a,$color){ foreach($a as $k=>$v){ if($v['color']===$color){ return true; } } return false; } function checkColors(Array &$a){ foreach($a as $k=>&$v){ switch($v['color']){ case 'blue': $appendColor = 'pink'; break; case 'green': $appendColor = 'blue'; break; case 'pink': $appendColor = 'green'; break; } if(hasColor($a,$appendColor)){ continue; } $a[] = ['color'=>$appendColor]; return checkColors($a); } } $colors = [ [ 'color'=>'blue' ] ]; checkColors($colors); var_dump($colors);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(1) { ["color"]=> string(4) "blue" } [1]=> array(1) { ["color"]=> string(4) "pink" } [2]=> array(1) { ["color"]=> string(5) "green" } }

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