嗨,我有一组数据库结果,我需要将它们组织成一个多维数组,这样我就可以通过一封电子邮件而不是多封电子邮件向用户发送他们的结果。
我从数据库中获得的值是名称、电子邮件、route_name、route_details。理想情况下,我想根据用户电子邮件将路线分组在一起,因为这是他们的唯一标识符。我认为以下内容对我有用。
Array
(
[email@email.com] => Array
(
[0] => name
[1] => Array
(
[0] => route_name
[1] => route_details
)
[2] => Array
(
[0] => route_name
[1] => route_details
)
)
[email2@email2.com] => Array
(
[0] => name
[1] => Array
(
[0] => route_name
[1] => route_details
)
[2] => Array
(
[0] => route_name
[1] => route_details
)
[3] => Array
(
[0] => route_name
[1] => route_details
)
)
)
任何帮助将不胜感激我在我的结果循环中尝试了以下内容,但我不确定如何根据电子邮件对结果进行分组,我不认为这正是我所需要的。
$routeArray = array($data->email ,array($data->route_name, $data->route_details));
$userEmailArray[] = $flightArray;
谢谢