ok, I've got the switch($functionVariable); working. Now, what if I want to use two different variables inside my function()? is this possible?
In example, my user wanted 2 rows, and 3 collumns, and all they would have to do is function(2,3)..?
So, back to my function(1) question...
Moderator: General Moderators
yea, bascially:
Code: Select all
function myFunction($var1, $var2) {
echo "$var1 - $var2";
}
myFunction(1,2);- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Code: Select all
function foo($x,$y){
for($i = 0; $i < $x; $i++){
echo '<tr>';
for($n = 0; $n < $y; $n++){
echo '<td>column</td>';
}
echo '</tr>';
}
}I was using tables as an example, but thanks. ^_^hob_goblin wrote:Code: Select all
function foo($x,$y){ for($i = 0; $i < $x; $i++){ echo '<tr>'; for($n = 0; $n < $y; $n++){ echo '<td>column</td>'; } echo '</tr>'; } }
You can always give default values in the function
Code: Select all
function getTable($numRows=5, $numCells=5, $bgcolor="#FFEECC")
{
$t = "<table bgcolor=" . $bgcolor . ">";
for($i =0; $i <= $numRows; $i++)
{
$t .= "\n<tr>\n";
for($j = 0; $j <= $numCells; ++$j)
{
$t .= "<td>ї" . $i . ' ' . $j . "]</td>";
}
$t .= "\n</tr>";
}
$t .= "\n</table>\n";
return $t;
}
$v = getTable();
$vv = getTable( 8, 4, "#FFGGEE" );
print($v);
print($vv);