Could someone help me ?
Create a function that accepts four string variables and returns a string that contains an HTML table element, enclosing each of the variables in its own cell.
PHP helps
Moderator: General Moderators
-
harlemblues
- Forum Newbie
- Posts: 3
- Joined: Sat May 02, 2009 11:19 pm
Re: PHP helps
Actually it's very easy, maybe you just started with php.
By the way, here's the solution:
By the way, here's the solution:
Code: Select all
function putInTable($s1,$s2,$s3,$s4){
$table ="<table border=\"1\">" .
"<tr><td>" . $s1 . "</td></tr>" .
"<tr><td>" . $s2 . "</td></tr>" .
"<tr><td>" . $s3 . "</td></tr>" .
"<tr><td>" . $s4 . "</td></tr>" .
"</table>";
return $table;
}
Last edited by Benjamin on Fri May 08, 2009 9:29 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.
Re: PHP helps
eh .. unless you really wanted a a function with 4 params .. I would recommend passing an array but .. you said string so here ya go ..
Code: Select all
function make_table($str1,$str2,$str3,$str4){
$table = <<<FO
<table>\r\n
<tr><td>{$str1}</td></tr>\r\n
<tr><td>{$str2}</td></tr>\r\n
<tr><td>{$str3}</td></tr>\r\n
<tr><td>{$str4}</td></tr>\r\n
</table>
FO;
return $table;
Last edited by Benjamin on Fri May 08, 2009 9:30 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.
Re: PHP helps
Well there goes the "we don't do your homework for you" policy...