i have an array with some employee data and i need to fill the gap for missing dates, i tried but i cannot get it to fill in the missing dates
from an search range: eg. FROM 2015-10-25 to 2015-10-26 current result:
[92] => Array
(
[0] => stdClass Object
(
[DT] => 2015-10-26
[CheckIn] => Array
(
[t] => 15:52
[label] => success
)
[CheckOut] => Array
(
[t] => 19:41
[label] => danger
)
[Hours] => 3.82
)
[56] => Array
(
[0] => stdClass Object
(
[DT] => 2015-10-25
[CheckIn] => Array
(
[t] => 12:05
[label] => danger
)
[CheckOut] => Array
(
[t] => 20:09
[label] => danger
)
[Hours] => 8.07
),
[1] => stdClass Object
(
[DT] => 2015-10-26
[CheckIn] => Array
(
[t] => 12:05
[label] => danger
)
[CheckOut] => Array
(
[t] => 20:09
[label] => danger
)
[Hours] => 8.07
)
)
as you can see the first one is missing 25th, i need need an loop to fill in the missing date.
should look like this:
[92] => Array
(
[0] => stdClass Object
(
[DT] => 2015-10-25
[CheckIn] => Array
(
[t] => NCO
[label] => danger
)
[CheckOut] => Array
(
[t] => NCO
[label] => danger
)
[Hours] => 3.82
),
[1] => stdClass Object
(
[DT] => 2015-10-26
[CheckIn] => Array
(
[t] => 15:52
[label] => success
)
[CheckOut] => Array
(
[t] => 19:41
[label] => danger
)
[Hours] => 3.82
)
[56] => Array
(
[0] => stdClass Object
(
[DT] => 2015-10-25
[CheckIn] => Array
(
[t] => 12:05
[label] => danger
)
[CheckOut] => Array
(
[t] => 20:09
[label] => danger
)
[Hours] => 8.07
),
[1] => stdClass Object
(
[DT] => 2015-10-26
[CheckIn] => Array
(
[t] => 12:05
[label] => danger
)
[CheckOut] => Array
(
[t] => 20:09
[label] => danger
)
[Hours] => 8.07
)
)
current loop, maybe you can help me implement something withing this:
//this is to join each user by their id
$result = array();
foreach ($r['d'] as $data) {
$id = $data->badgenumber;
if (isset($result[$id])) {
$result[$id][] = $data;
} else {
$result[$id] = array($data);
}
$date = $data->DT;
}
Thank you.