3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 'number1' => [ 'value' => 2, 'comparator' => '<=', 'compareTo' => 5, 'next' => '&&' ], 'number2' => [ 'value' => 230, 'comparator' => '>', 'compareTo' => 200, 'next' => '&&' ], 'number3' => [ 'value' => 1, 'comparator' => '==', 'compareTo' => 1, 'next' => '||' ], 'number3' => [ 'value' => 2, 'comparator' => '=', 'compareTo' => 2, 'next' => '||' ], ]; function comparator(array $ar) { $i = 0; $m = count($ar); $last = true; foreach ($ar as $compare) { $i++; switch($compare['comparator']) { case '<=': $bool = $compare['value'] <= $compare['compareTo']; break; case '>': $bool = $compare['value'] > $compare['compareTo']; break; case '==': $bool = $compare['value'] == $compare['compareTo']; break; } if ($i < $m) { switch($compare['next']) { case '||': $last = $last || $bool; break; case '&&': $last = $last && $bool; break; } } } return $last; } var_dump(comparator($arr));
Output for git.master, git.master_jit, rfc.property-hooks
bool(true)

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:
206.57 ms | 405 KiB | 5 Q