php - preg_match escape for backslashes -
i'm trying value html span element:
<span class=\"date-display-single\">1462732200</span>
i've tried below mentioned approach seems there issue backslahes used in above mentioned html element.
i came know using 4 backslashes can me, didn't! other approach achieve value inside html element mentioned above. i.e. 1462732200
<span class=\"date\-display\-single\">(.*?)<\/span>
don't parse html via preg_match()
, use
$html = '<span class=\"date-display-single\">1462732200</span>'; // new dom object $dom = new domdocument('1.0', 'utf-8'); // load html object ***/ $dom->loadhtml($html); //discard white space $dom->preservewhitespace = false; $htwo= $dom->getelementsbytagname('span'); // here u use desired tag echo $htwo->item(0)->nodevalue;
Comments
Post a Comment