Jump to content

The best way to create the function? (function creates html table)


sumolotokai

Recommended Posts

Hi again,

 

I have written the code below to create a function with four arguments that returns a string that contains a table element. This will contain each of the variables in its own cell. I was wondering, is this the best way to do it and if not, what is?

 

<?php 
function x ($a, $b, $c, $d) {
echo "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">\n";
echo "<tr><td>$a</td></tr>";
echo "<tr><td>$b</td></tr>";
echo "<tr><td>$c</td></tr>";
echo "<tr><td>$d</td></tr></table>";
}
echo x ('bert', 'ernie', 'geoff', 'pat');
?>

 

Thanks in advance

 

Sumo

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.