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

php dom document class

$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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -