Is there a better way to complete this simple task below? As with an array or even with another method?
<?PHP // current way if ($city != NULL) { $city = FilterALLHTML($city); } if ($state != NULL) { $state = FilterALLHTML($state); } if ($title != NULL) { $title = FilterALLHTML($title); } if ($division != NULL) { $division = FilterALLHTML($division); } ?>
Here is my current function
function FilterALLHTML($document) { //old array line //"'<[\/\!]*?[^<>]*//?//>'si",// strip html $text = strip_tags($document); $search = array ("/f.?u.?c.?k/i", "/(s|$).?h.?i.?t/i", '/(potspace|mycrib|palbolt)/i'); $text = preg_replace ($search, '', $text); return $text; }
UPDATE - Alright, my new feature after the suggestions from this post, thanks guys
function FilterALLHTML($var) { //old array line //"'<[\/\!]*?[^<>]*//?//>'si",// strip html if ($var != null){ $text = strip_tags($var); $search = array ("/f.?u.?c.?k/i", "/(s|$).?h.?i.?t/i", '/(potspace|mycrib|palbolt|pot space)/i'); $text = preg_replace ($search, '', $text); return $text; } return null; }
source share