I am writing a PHP plugin, which builds a multidimensional array, in the format below, so that it can be passed back to the template system and parsed as tags.
I am fetching the information from a database:
$SQL = SELECT `id`, `name`, `description` FROM (`events`) WHERE `event_category_id` = '1' AND `active` = 1 ORDER BY `name` asc
This is the array structure required:
Array (
[A] => Array (
[0] => Array(
[event_id] => 1
[event_name] => A - this event name starts with the letter A
[event_description] => Example Description)
[1] => Array(
[event_id] => 6
[event_name] => AB - this event ALSO starts with the letter A
[event_description] => Example Description)
)
[B] => Array (
[0] => Array(
[event_id] => 3
[event_name] => BA - Event name starts with letter B
[event_description] => Example Description)
[1] => Array(
[event_id] => 5
[event_name] => BB - Event name starts with letter B
[event_description] => Example Description)
)
)
Could someone point me in the right direction, so that from the returned data, it splits the events into the appropriate keys (alphabetical key), sored alpha by the event_name.
The end result is to have this
A - Ambulance Training - Apple Bobbing B - Badminton - Bowling