placing array results into html tables

Hi,

I am currently working on creating a code that grabs information from an array and places them into an html table. The only extra part is that I also have to separate the information within the array where there are colons and put them into separate table columns. I was able to create the code below, but just cant seem to get the tables to align or fit in the correct places. Any help or suggestion is really appreciated and thank you guys in advance.

[php]<?php
$nocolon = $colon = “”;

$feat = array(
“feat1” => “nocolon1:colog1”,
“feat2” => “nocolon2:colog2”,
“feat3” => “nocolon3:colog3”,
“feat4” => “nocolon4:colog4”,
);

foreach ($feat as $val){
$nocolon .= strstr($val, ‘:’, true);
$nocolon = $nocolon . “
”;

$colon .= strstr($val, ':', false);
$colon  = $colon . "<br />";

}

$nocolon = “
$nocolon”;
$nocolon = str_replace("
", “

”, $nocolon);
$colon = str_replace("
", “ ”, $colon);

echo <<<_END

$nocolon $colon
_END; ?>[/php]

Got help and figured it out. Just in case anyone is looking for something similar here is what I got.

[php]

<?php $feat = array( "feat1" => "nocolon1:colog1", "feat2" => "nocolon2:colog2", "feat3" => "nocolon3:colog3", "feat4" => "nocolon4:colog4", ); $tableData = ''; foreach($feat as $name => $dataAry) { $tableData .= "\n"; $tableData .= "{$name}\n"; foreach(explode(':', $dataAry) as $data) { $tableData .= "{$data}\n"; } $tableData .= "\n"; } ?> <?php echo $tableData; ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service