'Array divided into days of the week
I want the array to be divided into days of the week according to the date specified in BETWEEN
and AND
public static function showDataByEmployer($employer)
{
$sql = 'SELECT `WorkingDay`
FROM `status`
WHERE `WorkingDay` BETWEEN "2021-04-12" AND "2021-04-16"
AND NameFinish = :employer ';
$db = static::getDB();
$stmt = $db->prepare($sql);
$stmt->bindValue(':employer', $employer, PDO::PARAM_STR);
$stmt->execute();
$user_data = $stmt->fetchAll();
print_r($user_data);
}
What is the best way to display the data in an array by day of the week. My example :
Array
(
[0] => Array
(
[0] => Array
(
[WorkingDay] => 2021-04-12 00:00:00
[0] => 2021-04-12 00:00:00
)
[1] => Array
(
[WorkingDay] => 2021-04-12 00:00:00
[0] => 2021-04-12 00:00:00
)
[2] => Array
(
[WorkingDay] => 2021-04-12 00:00:00
[0] => 2021-04-12 00:00:00
)
)
[1]=> Array
(
[0] => Array
(
[WorkingDay] => 2021-04-13 00:00:00
[0] => 2021-04-13 00:00:00
)
[1] => Array
(
[WorkingDay] => 2021-04-13 00:00:00
[0] => 2021-04-13 00:00:00
)
[2] => Array
(
[WorkingDay] => 2021-04-13 00:00:00
[0] => 2021-04-13 00:00:00
)
)
)
Where [0] is monday 12-04, [1] is Tuesday 13-04 ect.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|