Home  >  Article  >  Backend Development  >  Convert each row and column of the HTML table into an array and collect table data

Convert each row and column of the HTML table into an array and collect table data

WBOY
WBOYOriginal
2016-07-25 09:10:091153browse
","{ tr}",$table); //Open source code OSPhP.COm.CN
  • $table = str_replace("","{td}",$table);
  • //Remove HTML tag
  • $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table); //OSPHP.COM.Cn open source
  • //Remove whitespace characters
  • $table = preg_replace("'([rn])[s]+'","",$table);
  • $table = str_replace(" ","",$table);
  • //Open source code OSPHP.COM .Cn
  • $table = str_replace(" ","",$table);
  • $table = explode('{tr}', $table);
  • array_pop($table); //PHP open source code
  • foreach ($ table as $key=>$tr) {
  • $td = explode('{td}', $tr);
  • array_pop($td);
  • $td_array[] = $td; //PHP open source code
  • }
  • return $td_array;
  • }
  • ?>
  • Copy code
    Convert each row and column of the HTML table into an array and collect table data
    1. //Convert each row and column of the HTML table into an array and collect table data
    2. function get_td_array($table) {
    3. $table = preg_replace("']* ?>'si","",$table);
    4. //OSPHP.COm.CN
    5. $table = preg_replace("']*?>'si","",$ table);
    6. $table = preg_replace("']*?>'si","",$table);
    7. $table = str_replace("


    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:Quentin Zervaas's DBONext article:Quentin Zervaas's DBO