[PHP] Nur bestimmte HTML Elemente filtern

Dieses Thema im Forum "Webentwicklung" wurde erstellt von Hapablap, 21. Oktober 2009 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 21. Oktober 2009
    Nur bestimmte HTML Elemente filtern

    Hi Leute,

    kann mir jemand sagen, wie man HTML nur teilweise aus einem String filtern kann? Also z.B. p, div, strong, b, i, usw. lassen, aber z.B. script und sowas filtern?
     
  2. 21. Oktober 2009
    AW: Nur bestimmte HTML Elemente filtern

    Stichwort: reguläre Ausdrücke

    PHP: preg_replace - Manual

    PHP:
    $string  preg_replace ( "/\[b\](.+?)\[\/b\]/i" "<b>$1</b>" $string );  // BBCode

    if ( preg_match ( "/<div>(.*?)<\/div>/i" $string $matches ))
    {
      print 
    "<pre>" ;
      
    print_r ( $matches );
      print 
    "</pre>" ;
    }
     
  3. 21. Oktober 2009
    AW: Nur bestimmte HTML Elemente filtern

    Ah ich hasse sie Danke, damit hat sich das erledigt, hab was nettes gefunden!

    - closed -
     
  4. 22. Oktober 2009
    AW: Nur bestimmte HTML Elemente filtern

    Ich brauch leider doch noch mal Hilfe ...
    Ich bekomms einfach nicht hin, dass er mir <script language="... filtert. Sobald mehr im Tag steht. Ich hab schon so viel versucht ...
    PHP:
    #if(preg_match_all('/<'.$tag.'[^>]*>(.*)<\/'.$tag.'>/iU', $text, $found))
    #if(preg_match_all('|<' . $tag .'[^>]*>(.*)</' . $tag .'[^>]+>|U', $text, $found))
    #if(preg_match_all('^<' . $tag . '[^>]*>(.*?)</' . $tag . '>$', $text, $found))
    if( preg_match_all ( '/<'  $tag  '*>(.*?)<\/'  $tag  '>/i' $text $found ))
    {
        
    $text  str_replace ( $found [ 0 ], $found [ 1 ], $text );
    }
    Hoffe mir kann jemand weiterhelfen!
     
  5. 23. Oktober 2009
    AW: Nur bestimmte HTML Elemente filtern

    PHP: strip_tags - Manual

    doku lesen
     
  6. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.