3v4l.org

run code in 300+ PHP versions simultaneously
<?php function address(){ $a = array(array ( "address" => "New York", "address_flag" => 0 ), array ( "address" => "London", "address_flag" => 1 ), array ( "address" => "Amsterdam","address_flag" => 1), array ( "address" => null, "address_flag" => null)); return $a; } $address = ""; $grouped_by_zero = array(); $grouped_by_one = array(); $array = address(); for ($i=0, $max = count($array); $i < $max; $i++ ){ foreach($array[$i] as $key => $value) { if ($key == "address") { $address = $value; } else if ($key == "address_flag") { if ( $value === 0){ array_push($grouped_by_zero, $address ); } else if ($value === 1) { array_push($grouped_by_one, $address ); } } } //end foreach }// end for foreach($grouped_by_zero as $item){ echo $item . "\n"; } echo "\n"; foreach($grouped_by_one as $item){ echo $item . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
New York London Amsterdam

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