Results 1 to 4 of 4

Thread: preg Problem

  1. #1
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755

    preg Problem

    Hi all,

    I've bumped into a small problem with ereg.

    I'm getting all the html links from a site, and making a list. That part works fine. But I want to list all the links that start with http://www. below them (so they could be listed twice). That part doesn't work.

    <?php
    $file_lines = file('http://www.example.com);

    foreach($file_lines as $file) {
    if(preg_match_all('#<a\s+?href=["\'](.+?)["\'].*?>#', $file, $matches)) {
    for ($i = 0; $i < count($matches[1]); $i++)
    echo $matches[1][$i] . '<br />';
    }
    }
    $match = implode("-", $matches);
    if(preg_match_all('#(http://www).+#', $match, $total)) {
    for ($x = 0; $x < count($total[1]); $x++)
    echo $total[1][$x] . '<br />';
    }
    ?>


    I get no errors, but the first list with all the links is the only thing that shows up.

    Anyone know what's wrong?

    Thanks a lot,
    Mike
    Last edited by Mike; 03-18-2004 at 09:57 AM.
    Don't you just love free internet games ?

  2. #2
    Isn't . a special character? Don't you have to escape it when matching it?

  3. #3
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Not sure, but I tried doing it and it still came up with the same result...
    Don't you just love free internet games ?

  4. #4
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    Anyone else?
    Don't you just love free internet games ?

Similar Threads

  1. viewing problem
    By fellboyzs in forum HTML, CSS, Layout, and Design
    Replies: 2
    Last Post: 05-05-2004, 06:15 PM
  2. Search Engine Friendly URLs Problem
    By cameron in forum Search Engine Optimization
    Replies: 5
    Last Post: 02-24-2004, 08:43 PM
  3. Strange DB Selection Problem
    By Mike in forum Website Programming & Databases
    Replies: 10
    Last Post: 02-12-2004, 01:06 PM
  4. Problem with my links
    By Mike in forum HTML, CSS, Layout, and Design
    Replies: 3
    Last Post: 11-15-2003, 03:25 PM
  5. My Problem
    By Chris in forum General Chat
    Replies: 10
    Last Post: 08-30-2003, 12:59 PM

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
  •