Answer:
So my issue turned out to be with the $eventValue and not the key. I was assuming the key was wrapped in brackets when it was added to the $days array but that was not the case. var_export showed me what really gets added to the array.
To solve the problem, I removed the enclosing quotes from the $eventValue as well as the trailing , comma.
Below is the original question:
Apologies as I do not know a whole lot of PHP, but I am trying to achieve something that I hope someone here can help with.
I have a loop that is finding specific days of a month to highlight on a calendar. In order for the calendar to highlight a specific day and wrap it in a class as well as a link tag, I need the array to be in this format:
$days = array(
2 => array('/weblog/archive/2004/Jan/02', 'linked-day'),
3 => array('/weblog/archive/2004/Jan/03', 'linked-day'),
8 => array('/weblog/archive/2004/Jan/08', 'linked-day'),
22 => array('/weblog/archive/2004/Jan/22', 'linked-day'),
);
Within my loop, I have these two variables:
$eventDay = substr("$str", -2, 2);
$eventValue = "array('http://example.com', 'linked-day'),";
and at the end of my loop I have this:
$days[$eventDay] = $eventValue;
The problem is, when I print_r ($days), my $eventDay key is wrapped in [] square brackets and so the day cannot be found by the calendar. I need to find a way to prevent it from being wrapped in brackets.
Perhaps I am approaching this all wrong. If someone has some suggestions I would really appreciate it.
I am using Keith Devens' PHP Calendar script to do this:
http://keithdevens.com/software/php_calendar
Thanks!
Full code:
Replace
$eventValue = "array('http://example.com', 'linked-day'),";
with
$eventValue = array('http://example.com', 'linked-day');
in line 44 of the pastie
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.