我正在编写一个 PHP 插件,它构建了一个多维数组,格式如下,以便可以将其传递回模板系统并解析为标签。
我正在从数据库中获取信息:
$SQL = SELECT `id`, `name`, `description` FROM (`events`) WHERE `event_category_id` = '1' AND `active` = 1 ORDER BY `name` asc
这是所需的数组结构:
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)
)
)
有人可以指出我正确的方向,以便从返回的数据中,将事件拆分为适当的键(字母键),按 event_name 排序 alpha。
最终的结果是拥有这个
A - 救护车训练 - Apple Bobbing B - 羽毛球 - 保龄球