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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:23:42+00:00 2026-05-25T02:23:42+00:00

I have this html content, there are 500 tables like this in the page.

  • 0

I have this html content, there are 500 tables like this in the page.

$html="
<table>
   <tbody>
   <tr> 
     <td>
        <br>
        <strong>
           <font face='times new roman'>No.1 &nbsp &nbsp >AP00001 </font>
        </strong>
        <br> 
        <table width=90%>
            <tr></tr>
            <tr>
               <td><font color='#01A078'>    10.295</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     2.808</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     3.744</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.936</font></td>
               <td><font color='#01A078'>     5.615</font></td>
               <td><font color='#01A078'>     1.872</font></td>
            </tr>
            <tr>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     1.872</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     2.808</font></td>
               <td><font color='#01A078'>     0.936</font></td>
               <td><font color='#01A078'>     0.000</font></td>
            </tr>
            <tr>
               <td>    31.227</td>
               <td>    37.888</td>
            </tr>
        </table>
      </td>
    </tr>
    <tr> 
     <td> 
        <br>
        <strong>
           <font face='times new roman'>No.2 &nbsp &nbsp >AP00002 </font>
        </strong>
        <br>
        <table width=90%>
            <tr></tr>
            <tr>
               <td><font color='#01A078'>    10.295</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     2.808</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     3.744</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.936</font></td>
               <td><font color='#01A078'>     5.615</font></td>
               <td><font color='#01A078'>     1.872</font></td>
            </tr>
            <tr>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     1.872</font></td>
               <td><font color='#01A078'>     0.000</font></td>
               <td><font color='#01A078'>     2.808</font></td>
               <td><font color='#01A078'>     0.936</font></td>
               <td><font color='#01A078'>     0.000</font></td>
            </tr>
            <tr>
               <td>    35.267</td>
               <td>    17.834</td>
            </tr>
        </table>
      </td>
    </tr>
     .
     .
     .
     .
   </tbody>
 </table>";

as you see the third <tr> is different , and I want to save that two number in variables ( 31.227 and 37.888) related with the value inside the <strong> element.

my desired output looks like this :

No.1 >AP00001 31.227 37.888
No.2 >AP00002 35.267 17.834
.
.
.

any help? how can I do that in PHP?

  • 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-25T02:23:43+00:00Added an answer on May 25, 2026 at 2:23 am
    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->loadHTML($html);
    $xpath = new DOMXPath($dom);
    $keys = array();
    $names = $xpath->query('//table/tbody/tr/td/strong/font');
    foreach ($names as $name){
        $keys []= trim($name->nodeValue);
    }
    $values = array();
    $trs = $xpath->query('//table/tbody/tr/td/table/tr[4]');
    foreach($trs as $tr) {
        $tds = $tr->getElementsByTagName('td');
        $values []= array(trim($tds->item(0)->nodeValue), trim($tds->item(1)->nodeValue));
    }
    $result = array_combine($keys, $values);
    echo '<pre>' . print_r($result, true) . '</pre>';
    

    Not the most elegant, but’ll do the job:

    Array
    (
        [No.1     >AP00001] => Array
            (
                [0] => 31.227
                [1] => 37.888
            )
    
        [No.2     >AP00002] => Array
            (
                [0] => 35.267
                [1] => 17.834
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
OK I have backgrounds set up like this: HTML <div id=container> <div id=content> CONTENT
I have some HTML that looks like this: <div class=product> Content In Here <div
I have a HTML table. Each cell has content of different length. For this
I have this html page I copied from here . There is a javascript
Suppose we have this html content, and we are willing to get Content1, Content2,..
I have this Haml view: !!! strict %html{:xmlns => http://www.w3.org/1999/xhtml} %head %meta{:content => text/html;
I have been using jQuery prettyPhoto plugin to show inline html content. This content
I have a table with 6 columns containing HTML content with some markups in
I have some HTML content (including formatting tags such as strong , images etc).In

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.