SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: preg_match_all

  1. #1
    Non-Member
    Join Date
    Oct 2006
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_match_all

    how could I use preg_match_all or some function to return the url and the text?

    I am using a site source (file_get_contents), and then finding the display block.

    Example

    Code:
    <a href="/tutorials/count/42539/setting_up_your_own_radio_station_with_winamp_and_set_up_your_own_shoutcast/" target="_blank" class="blue">1. Setting Up Your Own Radio Station With WinAmp and set up your own Shoutcast!</a>
    So how would I return this:
    Link: /tutorials/count/42539/setting_up_your_own_radio_station_with_winamp_and_set_up_your_own_shoutcast/

    Title: 1. Setting Up Your Own Radio Station With WinAmp and set up your own Shoutcast!

    I know you would need to use preg_replace_all and then a foreach, just not sure how.

    Thanks
    Dan
    Tutorial-Center.com

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    preg_match_all('#<a href="([^"]+)"[^>]*>(.*?)</a>#s'$html$matches);
    print_r($matches); 


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
  •