Revision [23714]

This is an old revision of PLG-Csv made by ThePLG on 2019-09-03 07:42:15.

 

CSV 2 Table formatter

See Also
NOT Included in any Wikka version yet
Last edited by ThePLG
Tue, 03 Sep 2019 07:42 UTC [diff]


This formatter converts inline csv data into a table.

Features



%%(csv)
;==/First Name/==;==\Last Name\==;==|Address|==;== Age ==
==Norwegian==;Sigurd;Nordmo;[[Viggo]] Hansteens allé 119\; 1524 MOSS; 38
==Swede==; Chanelle; Blomqvist; Överhogdal 95; 282 02 HÖRJA; 61
==German==; Leah; Ackermann; Landhausstraße 73; 15702 Königs Wusterhausen; 25
# Comments are possible. Yes, the following person is a Hobbit!
==Hobbit==;Celendine; "Gam gee"; ; 216
%%

 First NameLast NameAddress Age
Norwegian Sigurd Nordmo Viggo Hansteens allé 119; 1524 MOSS 38
Swede Chanelle Blomqvist Överhogdal 95; 282 02 HÖRJA 61
German Leah Ackermann "Landhausstraße 73; 15702 Königs Wusterhausen" 25
Hobbit Celendine "Gam gee"  216


 abc
1def
2g h
3IJK


Installation

Code
<?php
// convert inline csv data into a table.
// by OnegWR, may 2005, license GPL
$csv_printheader=0;
foreach(split("\n", $text) as $csv_n => $csv_line){
        if(preg_match("/^#|^\s*$/",$csv_line)) continue;
        if( $csv_printheader == 0){ print "<table cellpadding=\"5\" cellspacing=\"1\"><tbody>\n"; $csv_printheader=1; }
        print ($csv_n%2) ? "<tr bgcolor=\"#ffffee\">" : "<tr bgcolor=\"#eeeeee\">";
        foreach(split(";", $csv_line) as $csv_nn => $csv_cell){
                if(preg_match("/^\s*$/",$csv_cell)){
                        print "<td>&nbsp;</td>";
                }elseif(preg_match("/^(\"?)\*\*\*(.*?)\*\*\*(\"?)$/",$csv_cell,$matches)){
                        print "<td bgcolor=\"#cccccc\">".
                                $this->htmlspecialchars_ent($matches[2])."</td>";
                }elseif(preg_match("/^(\"?)(.*?)(\"?)$/",$csv_cell,$matches)){
                        print "<td>".$this->htmlspecialchars_ent($matches[2])."</td>";
                }else{
                        print "<td>".$this->htmlspecialchars_ent($csv_cell)."</td>";
                }
        }
        print "</tr>\n";
}
if( $csv_printheader == 1) print "</tbody></table>\n";
?>

History

TODO


CategoryUserContributions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki