This code is one that works for me. // Prevent iframes $text = preg_replace("/<iframe[^>]*>.*<*iframe[^>]*>/i", "", $text); // Prevent iframe $text = preg_replace("/<iframe[^>]*>/i", "", $text); PHP: The latter seems to work the best. Use both for best results though.