Необходимо получить массив вида:
Array (
[028ebaa9-e8dd-4eb3-aec0-2be5632da1fe] => Array (
[deliveryTime] => 2018-05-31 14:47
[token1] => token1
[tags] => tags1
[sendStatus] => sheduled
)
[a6352709-47d2-422e-ad84-86ea1249d805] => Array (
[deliveryTime] => 2018-05-31 14:47
[token1] => token2
[tags] => tags2
[sendStatus] => 0
)
[3716d438-7262-4bda-994d-fe055f4c5b56] => Array (
[deliveryTime] => 2018-05-31 14:47
[token1] => token2
[tags] => tags2
[sendStatus] => 0
)
)
Пробовал делать так:
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if ($send_date){
/*echo "id: " . $row["id"] . " playerID: " . $row["playerID"] . " deliveryTime: " . $row["deliveryTime"] . " token1: " . $row["token1"] . " tags: " . $row["tags"] . " sendStatus: " . $row["sendStatus"] ."<br>";*/
$playerID = array("playerID" => $row["playerID"]);
$deliveryTime = array("deliveryTime" => $row["deliveryTime"]);
$token1 = array("token1" => $row["token1"]);
$tags = array("tags" => $row["tags"]);
$sendStatus = array("sendStatus" => $row["sendStatus"]);
$temp_array0 = array_merge ($deliveryTime, $token1, $tags, $sendStatus);
$temp_array = array($row["playerID"] => $temp_array0);
}
}
} else {
echo "0 results";
}
print_r($temp_array);
Но, в таком случае получается:
Array ( [3716d438-7262-4bda-994d-fe055f4c5b56] => Array ( [deliveryTime] => 2018-05-31 14:47 [token1] => token2 [tags] => tags2 [sendStatus] => 0 ) )
while
укажите$arr = [];
, а потом в цикле указывайте$arr[$playerID] = $temp_array0;
- это как вариант..