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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:46:45+00:00 2026-05-27T08:46:45+00:00

I am using PHP/Regex to parse some data for an application. The pages I

  • 0

I am using PHP/Regex to parse some data for an application. The pages I am parsing have table formats that include a header followed by a bunch of items. What I am trying to do is get the header for each table, along with all of the items so that I can label each item as part of that group (defined by the header).

I currently have it set up with an expression matching each header, and then everything up to the next header. I then use a loop on the header count to match the additional data from the second match in the first expression.

So basically:

preg_match_all ('#table-header.*?>(.*?)<\/td>(.*?)table-header#s', $url, $gr, PREG_PATTERN_ORDER);

for($i = 0; $i < count($gr[0]); $i++) {
  preg_match_all ('#type_id.*?<b>(.*?)</b> ... #s', $gr[2][$i], $info, PREG_PATTERN_ORDER);
  $group = trim($gr[1][$i]);

  for($ii = 0; $ii < count($info[0]); $ii++) {
    $name = trim($info[1][$ii]);
    ...
   }
 }

My issue is that it is skipping every other group, what I can only assume is because it matches table-header to table-header, and then skips to the next table-header instead of starting the next match with the ending table-header of the first match. How can I get it to start the next match with the end point of the previous match? Unfortunately the pages do not have enough unique items near the beginning/end points to use something different to match. The code looks similar to this:

<td align='center' class='table-header' colspan='18' valign='top'>
    Header
</td>

...items...

<td align='center' class='table-header' colspan='18' valign='top'>
    Header 2
</td>

I tried using the colspan as the start of my expression, and grabbing everything up to the next table-header, but it just breaks.

Thanks for any suggestions.

  • 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-27T08:46:45+00:00Added an answer on May 27, 2026 at 8:46 am

    You should have a look to this class instead:
    http://simplehtmldom.sourceforge.net/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP, I can convert MySQL data or static table data to csv, Excel,
using php and mysql I have two tables, a users table and a profiles
I'm using php to process rss data, however often feeds have more than image
I am trying to parse text for email id's using php / regex. Are
Using PHP and MySQL, I have a forum system I'm trying to build. What
I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort
I need to be able to parse this sort of data in PHP: Acct:
I'm using PHP and trying to parse this subject line to isolate just the
I've been using the following site to test a PHP regex so I don't
I'm using PHP's preg_match_all() to search a string imported using file_get_contents(). The regex returns

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.