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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:15:10+00:00 2026-05-16T01:15:10+00:00

i have this html code. Im using Simple HTML Dom to parse the data

  • 0

i have this html code. Im using Simple HTML Dom to parse the data into my own php script.

<table>
    <tr>
        <td class="header">Name</td>
        <td class="header">City</td>
    </tr>
    <tr>
        <td class="text">Greg House</td>
        <td class="text">Century City</td>
    </tr>
    <tr>
        <td class="text">Dexter Morgan</td>
        <td class="text">Miami</td>
    </tr>
</table>

I need to get the text inside the TDs in an array, example:

$array[0] = array(‘Greg House’,’Century City’);
$array[1] = array(‘Dexter Morgan’,’Miami’);

I’ve tried several ways to get that but i’ve fail in each and everyone of them. Can someone give me a hand?

  • 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-16T01:15:11+00:00Added an answer on May 16, 2026 at 1:15 am

    This should do:

    // get the table. Maybe there's just one, in which case just 'table' will do
    $table = $html->find('#theTable');
    
    // initialize empty array to store the data array from each row
    $theData = array();
    
    // loop over rows
    foreach($table->find('tr') as $row) {
    
        // initialize array to store the cell data from each row
        $rowData = array();
        foreach($row->find('td.text') as $cell) {
    
            // push the cell's text to the array
            $rowData[] = $cell->innertext;
        }
    
        // push the row's data array to the 'big' array
        $theData[] = $rowData;
    }
    print_r($theData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for logging into Google using Simple DOM Parser with curl.
I'm using the Simple php DOM Parser to parse an html table and count
I have a script that gets embed code for me.I am using php simple
I have this two lines of html code... <div id=slider1 data-param1=XXX data-param2=XXX></div> <script src=script.js
I have this code in mvc 3 razor @using (Html.BeginForm(MyAction, MyController)) { <input type=text
i have this html code <table style=width: 100%;> <tr> <td> ID </td> <td> <input
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have this html code: <div class=action> some_text <a class=delete_action name=q1>some</a> </div> <div class=action>

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.