I'm updating my website to set the rDNS, however I'm here to ask your opinion on how this handle my issue. I have all IP's (IPv4) in a array called $aIP
. Now I have a list like this:
<tr><td>1.2.3.4</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=1">myserver.com</a></td></tr>
<tr><td>1.2.3.5</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=2"><i>not set</i></a></td></tr>
<tr><td>1.2.3.6</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=3"><i>not set</i></a></td></tr>
<tr><td>1.2.3.7</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=4">test.myserver.com</a></td></tr>
<tr><td>1.2.3.8</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=5"><i>not set</i></a></td></tr>
<tr><td>1.2.3.9</td><td>hostname.bla.com</td><td><a href="edit-reverse.cgi?id=6"><i>not set</i></a></td></tr>
Now I need the current rDNS value (in this case either myserver.com
or not set
or test.myserver.com
) and I need the value or the complete url which it links to (edit-reverse.cgi?id=1
or 1
) which is linked to the IP address in the array $aIP
.
This would be the expected output (not especially in this output format rather be in an array or something):
1.2.3.4 => 1, myserver.com
1.2.3.5 => 2, not set
1.2.3.6 => 3, not set
1.2.3.7 => 4, test.myserver.com
1.2.3.8 => 5, not set
1.2.3.9 => 6, not set
Please bear in mind that not all IP addresses I have might be in the $aIP
array, so basically it should loop through the HTML code and search for the values according to the $aIP
array.
I was thinking about using regex but then I don't know a lot about them so it would probably be very inefficient code. What would be the best way to handle this?