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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:41:26+00:00 2026-05-24T16:41:26+00:00

I just can’t seem to work out how to pull the entire table from

  • 0

I just can’t seem to work out how to pull the entire table from a page using regex.

This is my PHP:

$printable = file_get_contents('http://entertainment.soundboxaudio.com/testplaylist.htm');
$array = array();
preg_match( '/<TABLE>(.*?)<\/TABLE>/si', $printable, $array ) ;
$findit = "$array[1]";
echo("$findit");

Any help would be appreciated,

Thanks!

  • 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-24T16:41:29+00:00Added an answer on May 24, 2026 at 4:41 pm

    Here we go again… do NOT use regex to extract HTML. HTML is not a regular language and cannot be reliably analyzed with a regex. Use DOM instead.

    $printable = file_get_conttents('...');
    $dom = new DOMDocument;
    $dom->loadHTML($printable);
    $xpath = new DOMXpath($dom);
    
    $tables = $xpath->query("//table");
    
    $table_html = array();
    
    foreach($tables as $table) { // workaround for PHP DOM not support innerHTML
       $temp = new DOMDocument;
       $temp->appendChild($temp->importNode($table, true));
       $table_html[] = trim($temp->saveHTML());
    }
    

    As well, surrounding variables you’re echoing is just a waste of a string operation

    echo $x
    echo "$x";
    

    work identically, except the quoted version wastes some cpu produce a temporary string that only gets thrown away again.

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

Sidebar

Related Questions

I just can't work this one out. I have a table with a column
I'm new to regular expression and just can't seem to figure this out: '/^[A-Za-z0-9](?:.[A-Za-z0-9]+)$/'
I just can't seem to figure this one out... As far as I know,
I just can't figure this out. I have a script that gets data from
I just can't seem to figure this out - I'm trying to get the
I just can't seem to get this query figured out. I need to combine
I'm using GDI+ in a C++/MFC application and I just can't seem to avoid
I know this maybe a basic question but I just can't seem to find
This shouldn't be so hard but I just can't seem to get this to
I just can't seem to figure out how to make efficient and clean looking

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.