Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-25 09:10:09
Original
1186 people have browsed it
","{ 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("


    source:php.cn
    Statement of this Website
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template