How can I remove all elements from an array that contain only special characters (such as ., * etc...).
function only_specialchars($string) {
if (preg_match("/[a-z0-9]/i", $string)) {
return false;
} else {
return true;
}
}
$filtered = array_filter($array, "only_specialchars"));
Something like this? This will filter all words that do not contain characters or numbers.