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 8471133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:42:46+00:00 2026-06-10T16:42:46+00:00

I am using Simple DOM Parser and I am trying to get some info

  • 0

I am using Simple DOM Parser and I am trying to get some info from a dynamic table that will look like this:

<table />
<tr>
   <td class="histogram-msg top-row">5 star</td>
   <td class="top-row bar-cell"><span class="bar bar5" style="width:150px">&nbsp;</span>&nbsp;<span>55</span></td>
</tr>
<tr>
   <td class="middle-row histogram-msg">4 star</td>
   <td class="middle-row bar-cell"><span class="bar bar4" style="width:65px">&nbsp;</span>&nbsp;<span>24</span></td>
</tr>
<tr>
   <td class="middle-row histogram-msg">3 star</td>
   <td class="middle-row bar-cell"><span class="bar bar3" style="width:38px">&nbsp;</span>&nbsp;<span>14</span></td>
</tr>
<tr>
   <td class="middle-row histogram-msg">2 star</td>
   <td class="middle-row bar-cell"><span class="bar bar2" style="width:19px">&nbsp;</span>&nbsp;<span>7</span></td>
</tr>
<tr>
   <td class="bottom-row histogram-msg">1 star</td>
   <td class="bottom-row bar-cell"><span class="bar bar1" style="width:35px">&nbsp;</span>&nbsp;<span>13</span></td>
</tr>
</table>

I am trying grab the values in the table i.e. : 5 star | 55, 4 star | 24, etc.

I get this info by $ret = $html->find('.user-ratings'); and when I try to print the span tags it just give me a bunch of white space.

How can I grab the rating type and value from the table above?

  • 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-10T16:42:47+00:00Added an answer on June 10, 2026 at 4:42 pm

    This will do what you’re trying to do:

    <?php
    
    include('simple_html_dom.php');
    
    $f = file_get_html('s.html');
    
    foreach($f->find('td[class=histogram-msg]') as $n) {
    
    foreach($n->parent()->find('td[class=bar-cell]') as $p) {
        $ratings[] = array('stars' => $n->innertext, 
       'rating' => strip_tags(str_replace("&nbsp;", "", $p)));
        }
    }
    
    print_r($ratings);
    
    Array
    (
    [0] => Array
        (
            [stars] => 5 star
            [rating] => 55
        )
    
    [1] => Array
        (
            [stars] => 4 star
            [rating] => 24
        )
    
    [2] => Array
        (
            [stars] => 3 star
            [rating] => 14
        )
    
    [3] => Array
        (
            [stars] => 2 star
            [rating] => 7
        )
    
    [4] => Array
        (
            [stars] => 1 star
            [rating] => 13
        )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using Simple HTML DOM Parser to receive certain info that i require, but
I'm using simple-html-dom to try and pull some code from another site. Here's some
I have a working statement in PHP using the simple dom parser that I
I'm using the Simple php DOM Parser to parse an html table and count
I'm using PHP Simple HTML DOM Parser to grab some values I need. What
I am using PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/ to fetch data like Page
All I am using PHP Simple HTML DOM Parser to getting product details like
I am using PHP Simple HTML DOM Parser and it is consuming a lot
I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding
I'm using simple_html_dom.php to get all images from an url (like pinterest does) if($_POST['submit'])

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.