Jump to content

preg_match_all -> class="l">85.236.100.103 <img src="/i/launch.gif" title="Launc


scarhand

Recommended Posts

I am looking to match all occurances of this:

 

class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060

 

where "85.236.100.103" could be any IP address, and "29060" could be any port.

 

heres my code thats not working:

 

<?php
preg_match_all('|class="l">([0-9.]+) <img src="/i/launch.gif" title="Launch"/></a></td><td>([0-9]+)|', $content, $matches);
?>

Link to comment
Share on other sites

Your code works for me, maybe your real-world source is different than your sample:

<pre>
<?php
$content='class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060
class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060
class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060';
preg_match_all('|class="l">([0-9.]+) <img src="/i/launch.gif" title="Launch"/></a></td><td>([0-9]+)|', $content, $matches);
echo htmlentities(print_r($matches,true));
?>

output:

Array
(
    [0] => Array
        (
            [0] => class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060
            [1] => class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060
            [2] => class="l">85.236.100.103 <img src="/i/launch.gif" title="Launch"/></a></td><td>29060
        )

    [1] => Array
        (
            [0] => 85.236.100.103
            [1] => 85.236.100.103
            [2] => 85.236.100.103
        )

    [2] => Array
        (
            [0] => 29060
            [1] => 29060
            [2] => 29060
        )

)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.