2014-03-26 47 views

回答

1

試試這個,使用DOM文檔和DOMXPath

$str = '<span class="timestamp" data-time="1395846963">33m</span>'; 

$DOM = new DOMDocument(); 
$DOM->loadHTML($str); 

$XPATH = new DOMXPATH($DOM); 

$r = $XPATH->query("//span/@data-time"); 

var_dump($r->item(0)->nodeValue); 
+1

的偉大工程。你救了我 - TX! – mojoo

相關問題