3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ['keep', 'remove', 'save', 'keep', 'save', 'delete']; $array2 = ['hold', 'remove', 'keep', 'retain', 'keep', 'delete']; $map = array_combine($array1,$array2); $map = array_filter($map ,function ($item) use (&$map) { $keep_data = ($item != key($map)); next($map); return $keep_data; }); $clean1 = array_keys($map); $clean2 = array_values($map); var_export($clean1); echo "<br />"; var_export($clean2);
Output for 7.4.0 - 7.4.30, 8.0.1 - 8.0.22, 8.1.0 - 8.1.9
array ( 0 => 'keep', 1 => 'save', )<br />array ( 0 => 'retain', 1 => 'keep', )

preferences:
25.18 ms | 409 KiB | 5 Q