TT calendar library dayrangecolour
dayrangecolour -- Changes the colour of a range of days in a month array.

Description

array dayrangecolour(array month_array,string colour, int start[,int end])

Returns an array representing the display format of a given month with the "col" attribute for each of the range of days specified by start and end set to the string specified in colour. For details of the array format see the about the month arrays used by this library page.

month_array is an array representing the display format of a given month. For details of the array format see the about the month arrays used by this library page.

colour is an HTML colour, either as a hexadecimal string such as "#0000ff" or a text string such as "blue". For more information on valid colour names see the This W3C page.

start is the first date you wish to be set to the colour specified by colour.

end is an optional parameter representing the last date you wish to be set to the colour specified by colour. If this parameter is set, all the days between start and end inclusive have their "col" attribute set to colour. If it is not set, only the day specified by start is coloured.

Examples

The code below colours the 7th to the 15th of the month green.
include("ttcalendar.php");

$our_month = 3; #march
$our_year = 2004;
$month_array = returnmontharray($our_month,$our_year);

$month_array = dayrangecolour($month_array,"#00ff00",7,15); 

echo returnmonthhtml($month_array,"#ffffff");

Here is the HTML returned:
SMTWTFS
123456
78910111213
14151617181920
21222324252627
28293031

The code below colours the 20th of the month magenta.


include("ttcalendar.php");

$our_month = 3; #march
$our_year = 2004;
$month_array = returnmontharray($our_month,$our_year);

$month_array = dayrangecolour($month_array,"magenta",20); 

echo returnmonthhtml($month_array,"#ffffff");

Here is the HTML returned:
SMTWTFS
123456
78910111213
14151617181920
21222324252627
28293031

And finally, this code produces a random colour for every day of the month, as shown in one of the examples on an earlier page of this documentation.


include("ttcalendar.php");

$our_month = 1; #january
$our_year = 2004;
$month_array = returnmontharray($our_month,$our_year);

for ($i = 1; $i <= returnmonthlength($our_month,$our_year); $i++) {
    $colour = dechex(rand(0,255)) . dechex(rand(0,255)) . dechex(rand(0,255));
    $month_array = dayrangecolour($month_array,"#" . $colour,$i); 
}

echo returnmonthhtml($month_array,"#ffffff");

returnmontharray Contents daycolour