views:

69

answers:

2

I need to make an array in php that will output an html table so I can grab the source.

##id:1## ##site:1##

##id:2## ##site:2##

etc. 500 times over.
+4  A: 
<table>
<?
for($i = 0; $i < 500; ++$i) {
  echo '<tr><td>',$i,'</td><td>',$i,'</td></tr>';
} ?>
</table>

people are really lazy these days …

knittl
I actually looked for a while before asking, but thanks a lot this will come in handy for the future. Appreciate it.
shouldn't the , be . ?
easement
@easement no, echo allows commas as well.
Anti Veeranna
+1  A: 

i dont really know what u need that for but here is my solution (not tested)

$table_array=array(
    {id}=>'{text}',
    {id2}=>'{text2}'
);

echo '<table>';
foreach($id=>$row in $table_array){
    echo '<tr id="'.$id.'">';
    echo '<td>'.$row.'</td>';
    echo '</tr>';
}
echo '</table>';

You just have to generate the Array with the right text and id, then it should work fine.

Gushiken