2015-07-02 26 views

回答

0

您可以用PHP DOM做到这一点很容易;)

$dom = new DOMDocument(); 
$dom->loadHTML('<strong>title</strong>Hello World<strong>Sub-Title</strong><div>This is just stuff</div>'); 
$xpath = new DOMXPath($dom); 
// use the fact that PHP DOM wraps everything into the body and get the text() 
$entries = $xpath->query('//body/text()'); 
foreach ($entries as $entry) { 
    echo $entry->nodeValue; 
}