php - Extract text between 2 strings? -
this question has answer here:
- how parse , process html/xml in php? 27 answers
i have huge html page contains multiple data this
<td style="font-size:24px;" bgcolor="#f0f0f0" width="60%"> <strong>id:full name:email@email.com:mobile:country</strong> </td>
i want extract data between tags id:full name:email@email.com:mobile:country
so regex or custom php function?
ps: above code being repeated multiple times in page , want data stored in array.
as of others has said, can use domdocument
, domxpath
. this:
$html = '<td style="font-size:24px;" bgcolor="#f0f0f0" width="60%"> <strong>id:full name:email@email.com:mobile:country</strong></td>'; $dom = new domdocument(); $dom->loadhtml($html); $xpath = new domxpath($dom); $text = $xpath->query('//td/strong')->item(0)->nodevalue; echo $text; // id:full name:email@email.com:mobile:country
Comments
Post a Comment