<?php
$input = [
"Lincoln Crown",
"Crown Court",
"go holiday",
"house fire",
"John Hinton",
"Hinton Jailed"
];
$output = [];
while ($input) {
$output[] = $words = array_shift($input);
$input = preg_grep('~\b(?:\Q' . str_replace(' ', '\E|\Q', $words) . '\E)\b~', $input, PREG_GREP_INVERT);
}
var_export($output);
- Output for 7.1.0 - 7.1.33, 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 Crown',
1 => 'go holiday',
2 => 'house fire',
3 => 'John Hinton',
)
preferences:
139.69 ms | 408 KiB | 5 Q