What is the PHP equivalent for this Perl code?
my $html = '<tr class="aaa"><td class="bbb">111.111.111.111</td><td>443</td><td><div><span class="ccc"></span> example <span> example</span></div></td></tr><tr class="aaa"><td class="bbb">222.222.222.222</td><td>443</td><td><div><span class="ccc"></span> example <span> example</span></div></td></tr>';
print "$1:$2\n" while $html =~ /class="aaa"><td class="bbb">(.*?)<\/td><td>(\d+)<\/td>/g;
I tried with this code, but it gives infinite loop.
while(preg_match('/td class=\"bbb\">(.*?)<\/td><td>(\d+)<\/td>/',$html,$out)) {
echo "$out[1]:$out[2]\n";
}
Also, with if
instead of while
it gives only one result.
Expected output (IP:PORT):
111.111.111.111:443
222.222.222.222:443
Environment: Windows 7 with PHP 5.5.12 (WAMP v2.5).