function phpentities($text) { $search = array("&", "\"", "'", "\\", "<", ">"); $replace = array("&", """, "'", "\", "<", ">"); $text = str_replace($search, $replace, $text); return $text; }