Hi all, new to this language and don't plan to do it regularly. I lifted this code from the O'Reilly php hacks book. It's for a calendar and it's full of bugs. I fixed the bug that prevented this script from ever displaying January(posted on other thread). But here is another problem that prevents any of the events you enter from ever displaying.
Here's the call:
setCalendarText( &$days, $month + 1, 5, $year, "Hello Earl" );
Here's the original routine;
function setCalendarText( $days, $m, $d, $y, $text )
{
foreach( $days as $day )
{
if ( $day->get_day() == $d &&
$day->get_month() == $m &&
$day->get_year() == $y )
$day->set_text( $text );
}
}
The calling routine is expecting that $days gets updated but it doesn't. So really, this routine does nothing since it just mods a local $day and does nothing with it.
So here is my modified code using array subscripts:
function setCalendarText( $days, $m, $d, $y, $text )
{
for ($ii=1; $ii<count($days);$ii++)
{
if ( $days[$ii]->get_day() == $d &&
$days[$ii]->get_month() == $m &&
$days[$ii]->get_year() == $y )
{
$days[$ii]->set_text( $text );
}
}
}
Question: Is there a one-liner that I could have thrown in the original to basically $days(x) := $day (yes, I normally program in a different language so I don't know the syntax and the one book I have is no help).
Thought I'd share this. I'm surprised I haven't found more posts here and elsewhere about this buggy code(I've fixed 2 bugs with one to go). I still need to debug the part where the last few days of January display as 6 digit numbers on February's calendar.
cheers and keep your stick on the ice!