0

I have a huge HTML page that contains multiple data like this

<td style="font-size:24px;" bgcolor="#F0F0F0" width="60%">
    <strong>ID:Full Name:email@email.com:Mobile:Country</strong>
</td>

I want to extract the data between the tags which is ID:Full Name:email@email.com:Mobile:Country

So what would be the regex or any custom PHP Function?

PS: The above code is being repeated multiple times in a page and I want all that data to be stored in an array.

darryn.ten
  • 6,784
  • 3
  • 47
  • 65
Noman Riffat
  • 187
  • 2
  • 2
  • 16

1 Answers1

0

As of others has said, you can just use DOMDocument and DOMXpath. Like 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