Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5957077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:20:58+00:00 2026-05-22T18:20:58+00:00

After using curl i’ve got from an external page i’ve got all source code

  • 0

After using curl i’ve got from an external page i’ve got all source code with something like this (the part i’m interested)

   (page...)<td valign='top' class='rdBot' align='center'><img src="/images/buy_tickets.gif" border="0" alt="T"></td> (page...)

So i’m using preg_match_all, i want to get only “buy_tickets.gif”

$pattern_before = "<td valign='top' class='rdBot' align='center'>";
$pattern_after = "</td>";
$pattern = '#'.$pattern_before.'(.*?)'.$pattern_after.'#si';

preg_match_all($pattern, $buffer, $matches, PREG_SET_ORDER);

Everything fine up to now… but the problem it’s becase sometimes that external pages changes and the image i’m looking for it’s inside a link

(page...)<td valign='top' class='rdBot' align='center'><a href="blaa" title="ble"><img src="/images/buy_tickets.gif" border="0" alt="T"></a></td> (page...)

and i dunno how to get always my code to work (not just when the image gets no link)

hope u understand

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:20:58+00:00Added an answer on May 22, 2026 at 6:20 pm

    Don’t use regex to parse HTML, Use PHP’s DOM Extension. Try this:

    $doc = new DOMDocument;
    
    @$doc->loadHTMLFile( 'http://ventas.entradasmonumental.com/eventperformances.asp?evt=18' ); // Using the @ operator to hide parse errors
    
    $xpath  = new DOMXPath( $doc );
    
    $img = $xpath->query( '//td[@class="BrdBot"][@align="center"][1]//img[1]')->item( 0 ); // Xpath->query returns a 'DOMNodeList', get the first item which is a 'DOMElement' (or null)
    
    $imgSrc = $img->getAttribute( 'src' );
    
    $imgSrcInfo = pathInfo( $imgSrc );
    
    $imgFilename = $imgSrcInfo['basename']; // All you need
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a 'rolling' cURL multi implementation (like this SO post , based on
After using PHP for a while now, I've noticed that not all built-in PHP
if Form.Release is called after using the form, it will free all related memory
I have a UITextView with scrolling disabled, and I am using the page-curl transition
I need to get the final URL after a page redirect preferably with curl
I'm working with cURL, and needing to change my headers after using curl_exec(). But
i get page in utf-8 with russian language using curl. if i echo text
I'm using cUrl to POST to a web page (not local) and then return
I'm using curl to fill a form. After completion of the post the other
I am trying to download a tarball from GitHub using cURL , but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.