SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: preg_match

  1. #1
    Lost
    Join Date
    Dec 2002
    Location
    Norway
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_match

    Well.. it's been 5 hours since I started on trying to get this to work, but I give up.

    This is what I've gotten so far:

    PHP Code:
    <?php
    $url 
    =
    "[url=http://www.snaganame.com/index.php?keyword=&max_length=&location=anywhere&com=on&net=&submit=SEARCH&numbers=&hyphens=&rpp=50&char_match=less&drop_date[3]=1053921600&order=domain&start=50]http://www.snaganame.com/index.php?keyword=&max_length=&location=anywhere&com=on&net=&submit=SEARCH&numbers=&hyphens=&rpp=50&char_match=less&drop_date[3]=1053921600&order=domain&start=50[/url]";
    $file fopen($url"r");
    preg_match('/nowrap<b>([^<]*)<\/b>/i'$file$matches);
    echo 
    $matches "<br>"
    ?>

    OBS: I have no idea what I'm doing atm, so this script might be a total screw up.

    Anyway.. what I want is to receive everything on this page: =1053921600&order=domain&start=50]http://www.snaganame.com/index.php?keyword=&max_length=&location=anywhere&com=on&net=&submit=SEARCH&numbers=&hyphens=&rpp=50&char_match=less&drop_date[3]=1053921600&order=domain&start=50

    if it's between nowrap<b> and </b>

    It can't be that hard can it?

  2. #2
    SitePoint Enthusiast mind21_98's Avatar
    Join Date
    Apr 2003
    Location
    Inside, away from the light.
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by darker
    You'll need to read the data from the URL first:

    PHP Code:
    $stuff file_get_contents("http://www.microsoft.com/");
    preg_match('/nowrap<b>([^<]*)<\/b>/i'$file$matches);
    echo 
    $matches "<br>"
    I hope that helps.

  3. #3
    Lost
    Join Date
    Dec 2002
    Location
    Norway
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did help a little bit, but I'm still pretty much stuck.

    Darn.. Anyone able to help me out here before I totally give up?

  4. #4
    Lost
    Join Date
    Dec 2002
    Location
    Norway
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll redefine my question a little bit:

    After some concideration I've decided to approach this from another angle.

    Here's the deal now:

    What I need is to extract domain names from a huge .txt file.

    The txt file will contain about 100k of names, and each line will be something like this:

    asd.com 25/07/03
    asdas.com 25/07/03

    etc.

    So, what I need is some help to extract all these .coms into a variable.

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well: if that is the format - loop over each line and do this:
    PHP Code:
    <?php 
    // Loop over all lines here 
    $line "asd.com 25/07/03";  
    $arr explode(" "$line ); 
    echo 
    $arr[0] ; // prints 'asd.com', collect this for later use or print it somewhere.
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •