-3

I get html source include these domains (not http://)

ex:

<table>
<tr><td>abc.com</td></tr>
<tr><td>abc.net</td></tr>
<tr><td>abc.com.vn</td></tr>
<tr><td>abc.vn</td></tr>
</table> 

how I have to do with Regular Expresion export domains ?

1 Answers1

2

You can do like this to extract your domains..

<?php
$content ="<table>
<tr><td>abc.com</td></tr>
<tr><td>abc.net</td></tr>
<tr><td>abc.com.vn</td></tr>
<tr><td>abc.vn</td></tr>
</table>";
preg_match_all('/<td>(.*?)<\/td>/', $content, $matches);
print_r($matches[1]);

OUTPUT :

Array
(
    [0] => abc.com
    [1] => abc.net
    [2] => abc.com.vn
    [3] => abc.vn
)
Shankar Damodaran
  • 65,155
  • 42
  • 87
  • 120