3v4l.org

run code in 300+ PHP versions simultaneously
<?php $equation = '1-1'; $stored = $equation; $components = preg_split('~([*/%+-])~', $stored, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); while (($index = array_search('*', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] * $components[$index + 1]); } while (($index = array_search('/', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] / $components[$index + 1]); } while (($index = array_search('%', $components)) !== false) { array_splice($components, $index - 1, 3, fmod($components[$index - 1], $components[$index + 1])); } while (($index = array_search('+', $components)) !== false) { array_splice($components, $index - 1, 3, $components[$index - 1] + $components[$index + 1]); } $count = 0; var_dump($components); while (($index = array_search('-', $components)) !== false) { echo "First\n"; var_dump($components); array_splice($components, $index - 1, 3, $components[$index - 1] - $components[$index + 1]); echo "Second\n"; var_dump($components); $count++; if($count > 3) die('Too many'); } echo current($components);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/IhW94 on line 6 array(3) { [0]=> string(1) "1" [1]=> string(1) "-" [2]=> string(1) "1" } First array(3) { [0]=> string(1) "1" [1]=> string(1) "-" [2]=> string(1) "1" } Second array(1) { [0]=> int(0) } 0

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:
27.08 ms | 406 KiB | 5 Q