3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ['keepThis', 'remove', 'keep', 'save', 'delete', 'extra']; $array2 = ['hangOnto', 'remove', 'retain', 'keep', 'delete']; $clean1 = $array1; $clean2 = array_diff_ukey( $array2, $array1, // Need to have "&" so the values get set. function($a, $b) use (&$clean1, $array1, $array2) { // Use isset() just in case keys are not identical // or arrays are not the same length. if (isset($array2[$b]) && $array2[$b] === $array1[$b]) { unset($clean1[$b]); } return strcmp($array2[$a], $array1[$b]); }); print_r($clean1); print_r($clean2);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => keepThis [2] => keep [3] => save [5] => extra ) Array ( [0] => hangOnto [2] => retain )

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