3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_subtract(array $source, array $subtractor) { foreach ($subtractor as $subtractorItem) { $subtractorKey = array_search($subtractorItem, $source, true); if ($subtractorKey !== false) { unset($source[$subtractorKey]); } } return array_values($source); } var_dump(array_subtract([ 't', 'e', 's', 't' ], [ 't' ])); // [ 'e', 's', 't' ] var_dump(array_subtract([ 't', 'e', 's', 't' ], [ 't', 't' ])); // [ 'e', 's' ] var_dump(array_subtract([ 't', 'e', 's', 't' ], [ 't', 'e', 's', 't' ])); // [] var_dump(array_subtract([ 't', 'e', 's', 't' ], [ 'x' ])); // [ 't', 'e', 's', 't' ]
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> string(1) "e" [1]=> string(1) "s" [2]=> string(1) "t" } array(2) { [0]=> string(1) "e" [1]=> string(1) "s" } array(0) { } array(4) { [0]=> string(1) "t" [1]=> string(1) "e" [2]=> string(1) "s" [3]=> string(1) "t" }

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