3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ "Lincoln Crown", "Crown Court", "go holiday", "house fire", "John Hinton", "Hinton Jailed" ]; $output = []; $blacklist = []; foreach ($input as $string) { $words = explode(' ', $string); foreach ($words as $word) { if (in_array($word, $blacklist)) { continue 2; } } array_push($blacklist, ...$words); $output[] = $string; } var_export($blacklist); echo "\n"; var_export($output);
Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 0 => 'Lincoln', 1 => 'Crown', 2 => 'go', 3 => 'holiday', 4 => 'house', 5 => 'fire', 6 => 'John', 7 => 'Hinton', ) array ( 0 => 'Lincoln Crown', 1 => 'go holiday', 2 => 'house fire', 3 => 'John Hinton', )

preferences:
89.68 ms | 408 KiB | 5 Q