Array
(
[0] => tt0087523
[1] => cehennem melekleri
[3] => euer weg führt durch die hölle
[5] => guerreiros selvagens
[7] => jungel krigerne
[9] => jungle fever
[11] => jungle warriors
[17] => jungle warriors euer weg führt durch die hölle
[19] => la guerra de la coca
[21] => les guerriers de la jungle
[23] => los guerreros de la jungla
[25] => the czar of brazil
[27] => viidakkosoturit
)
How would I remove all values that are a substring of another value. For example remove index [3] as it is a substring of [17] and also [11] as that is also a substring of 17.
I am building a string for text search and wanted it to be as short as possible.
Update: re: comments :)
foreach ($array as $i => $value) {
foreach ($array as $j => $search) {
if ($i === $j) continue;
if (false !== stripos($search, $value)) {
unset($array[$i]);
}
}
}