//字符串过滤html和img function trimall($str) { $qian = array(" ", " ", "\t", "\n", "\r", " ", "&", "nbsp", ";"); $str = str_replace($qian, '', $str); preg_replace('/<\s+img[^>]+>/i', '', $str); preg_replace('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', '', $str); return preg_replace("/<img.*?>/si", "", $str); }