0

我使用simplehtmldom.sourceforge.net

我需要清晰的元素$e <font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>

我使用功能:$e->clear()元素删除,但离开</font>

如何彻底清洁元件?

4

1 回答 1

0

我从来没有使用过这个库,但正在浏览它。看看这是否能解决问题..

echo str_get_html('<font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>')->plaintext;

或这个 。.

$tagtext = (string)"<font size="2"><b>Listen to INT_routine on the January 15th, 2007 Urban-D Radio Podcast!</b></font>";
var_dump(str_get_html($tagtext)->plaintext);

编辑:

// Example 

$html = str_get_html("<div>foo <b>bar</b></div>");  
$e = $html->find("div", 0); 

echo $e->tag; // Returns: " div" 

echo $e->outertext; // Returns: " <div>foo <b>bar</b></div>" 

echo $e->innertext; // Returns: " foo <b>bar</b>"

echo $e->plaintext; // Returns: " foo bar"
于 2011-08-17T01:48:09.607 回答