...

View Full Version : Convert Array to a simpler Array



brandonlee
06-20-2010, 05:41 AM
How can I convert an array #EVENTS_ARRAY to look like #CALENDAR_ARRAY.
The keys must be the day of the month.
The key values can be empty.
The CI calendar library requires this simple array and I want to provide all of the summarized info in the value for customization reasons.

Basically the #CALENDAR_ARRAY contains the same data but is summarized and includes a count of how many events occur on one day.

If the counting events for each day is too complicated can it be done in the mysql statement and possibly be included in the first array?



# EVENTS ARRAY #
Array
(
[0] => Array
(
[uid] => 111
[birthday_date] => 1958-06-02
[name] => Name 1
)

[1] => Array
(
[uid] => 222
[birthday_date] => 1958-06-03
[name] => Name 2
)

[2] => Array
(
[uid] => 333
[birthday_date] => 1958-06-03
[name] => Name 3
)

[3] => Array
(
[uid] => 444
[birthday_date] => 1958-06-05
[name] => Name 4
)
)



# CALENDAR ARRAY #
Array
(
[1] =>
[2] => 1 entry, Name 1, 111
[3] => 2 entries, Name 2, 222 - Name 3, 333
[4] =>
[5] => 1 entry, Name 4, 444
)

The following is also acceptable.

Array
(
[2] => 1 entry, Name 1, 111
[3] => 2 entries, Name 2, 222 - Name 3, 333
[5] => 1 entry, Name 4, 444
)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum