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

  • SEARCH
  • Home
  • 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 8076051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:10:56+00:00 2026-06-05T15:10:56+00:00

Possible Duplicate: How to parse and process HTML with PHP? I am brand new

  • 0

Possible Duplicate:
How to parse and process HTML with PHP?

I am brand new to php, only a couple of hours in, trying to understand searching and finding. Let’s say I want to extract the rank of Diablo 3 from Amazon’s top seller list here. There I can search for the string “Diablo III” or similar to find the following block (sorry about the formatting):

 http://www.amazon.com/Diablo-III-Standard-Edition-Pc/dp/B00178630A/ref=zg_bs_4924894011_1
 "><img src="http://ecx.images-amazon.com/images/I/41kXCp%2BUyeL._SL160_SL160_.jpg" alt="Diablo III: Standard Edition" title="Diablo III: Standard Edition" onload="if (typeof      uet == 'function') { uet('af'); }"/></a></div></div><div class="zg_itemRightDiv_normal"><div class="zg_rankLine"><span class="zg_rankNumber">1.</span><span class="zg_rankMeta"></span></div><div class="zg_title"><a  href="

 
 ">Diablo III: Standard Edition</a></div><div class="zg_byline">by Blizzard Entertainment

Now, I want to try to extract the rank, which is defined in this part <span class="zg_rankNumber">1.</span> and is currently 1.

Could someone please advise on the best way on extracting that number so that if it falls to second, third or whatever place (up until 20) I will still be able to extract it?

I have looked a bit into preg_match and regex but I couldn’t quite understand the use.

  • 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-06-05T15:10:57+00:00Added an answer on June 5, 2026 at 3:10 pm

    You can start using Simple dom html parser
    So, if you wanna find this:

    <span class="zg_rankNumber">
    

    you can do it like this: ($str contains the html data)

    $html = str_get_html($str);
    echo $html->find("span[class='zg_rankNumber']",0)->innertext;
    

    EDITED:

    If you want to get a specific rank of game (Diablo III), then based on formatting, you just call:

    echo $html->find("img[title^='Diablo III']",0)->find("span[class='zg_rankNumber']",0)->innertext;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to parse and process HTML with PHP? $content = <p>This is
Possible Duplicate: How to parse and process HTML with PHP? Here is what I'm
Possible Duplicate: How to parse and process HTML/XML with PHP? I want to grab
Possible Duplicate: How to parse and process HTML with PHP? I'm not very good
Possible Duplicate: How to parse and process HTML with PHP? I'm looking into HTML
Possible Duplicate: Best methods to parse HTML with PHP I understand I should be
Possible Duplicate: How to parse and process HTML with PHP? How do I go
Possible Duplicate: How to parse and process HTML with PHP? I've tried to figure
Possible Duplicate: How to parse and process HTML with PHP? I know file_get_contents(url) method,
Possible Duplicate: How to parse and process HTML with PHP? i get page with

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.