PHP converts each row in an HTML table to an array to achieve the method of collecting tabular Data _php tutorial

Source: Internet
Author: User

PHP converts each row in an HTML table to an array to achieve the method of collecting tabular data


This example describes how PHP collects tabular data by converting each column of an HTML table into an array. Share to everyone for your reference. Specific as follows:

The following PHP code can convert each row of an HTML table to an array, collecting tabular data

 
  ]*?> ' si ', ' ", $table);  $table = Preg_replace ("'
 
  
   
  ]*?> ' si", "", $table);  $table = Preg_replace ("'
  
   
    
   ]*?> ' si", "", $table);  $table = Str_replace ("", "{tr}", $table);  $table = Str_replace ("", "{td}", $table);  Remove HTML markup   $table = Preg_replace ("' <[/!") *? [^<>]*?> ' si ', ' ", $table);  Remove whitespace characters   $table = Preg_replace ("' ([RN]) [s]+ '", "", $table);  $table = Str_replace ("", "" ", $table);  $table = Str_replace ("", "" ", $table);  $table = Explode (' {tr} ', $table);  Array_pop ($table);  foreach ($table as $key = + $tr) {    $td = explode (' {TD} ', $TR);    Array_pop ($TD);    $TD _array[] = $td;  }  return $TD _array;}? >
  
   
 
  

http://www.bkjia.com/PHPjc/979234.html www.bkjia.com true http://www.bkjia.com/PHPjc/979234.html techarticle PHP converts each row of an HTML table into an array to collect tabular data The example in this paper describes how PHP can collect tabular data by converting each column of the HTML table into an array. Share to the big ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.