Im using the following code quite often and wish to take some of the code and put it into a function and call the funtion and still output the array data.
This is what i have:
for($i = 1; $i <= $years; $i++)
{
$month = rand(1, 3);
if($month == 1)
{
$holis[$i][0] = "April";
$holis[$i][1] = $april;
}
elseif($month == 2)
{
$holis[$i][0] = "May";
$holis[$i][1] = $may;
}
elseif($month == 3)
{
$holis[$i][0] = "August";
$holis[$i][1] = $august;
}
$total = $total + $holis[$i][1];
echo "Year $i holidays are in {$holis[$i][0]} and you get {$holis[$i][1]} days worth of holidays.<br />\
\ ";
}
I wish to make it something like this, use a functon to set and check the month before outputing the data
function setMonth()
{
$month = rand(1, 3);
if($month == 1)
{
$holis[$i][0] = "April";
$holis[$i][1] = $april;
}
elseif($month == 2)
{
$holis[$i][0] = "May";
$holis[$i][1] = $may;
}
elseif($month == 3)
{
$holis[$i][0] = "August";
$holis[$i][1] = $august;
}
}
if($option == 1)
{
echo "<p>\
\ ";
for($i = 1; $i <= $years; $i++)
{
setMonth();
$total = $total + $holis[$i][1];
echo "Year $i holidays are in {$holis[$i][0]} and you get {$holis[$i][1]} days worth of holidays.<br />\
\ ";
}
}
Ive tried different things to get setMonth() to output the data