Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post

    Problems with preg_replace..

    Hey guys.... I'm using this code:

    PHP Code:
    $cat_names[] = preg_replace('~.*<li><a href="/search\.php\?cat=1">(.*?)</a></li>.*~is'"$1"$main_line); 
    Now...... shouldn't it be returning what is between the <a></a> tags (The name of the link)? Problem is...... it's returning the whole line.

    Any help?

  • #2
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    preg_match_all('/<li><a href="/search.php[^"]+">(.*?)</a></li>/is'$lines$matches);
    print_r($matches[1]); 
    $matches[1] should be an array of the link contents.

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Thanks...... I got my original code working tho..... the code on the page had changed slightly & now that I adjusted it works fine.


  •  

    Posting Permissions

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