- array_push: documentation ( source)
- var_export: documentation ( source)
- explode: documentation ( source)
- in_array: documentation ( source)
<?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);