<?php
$arr = json_decode('
[
{
"log_id": 1310,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "11:56",
"check_out": "17:25",
"date": "2019-03-23",
"time_long": "5:28",
"leaveId": 5,
"leaveLong": 16,
"leaveFrom": "2019-03-15",
"leaveTo": "2019-03-17"
},
{
"log_id": 1311,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "07:14",
"check_out": "17:24",
"date": "2019-03-24",
"time_long": "10:9",
"leaveId": 5,
"leaveLong": 16,
"leaveFrom": "2019-03-15",
"leaveTo": "2019-03-17"
},{
"log_id": 1312,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "06:58",
"check_out": "17:21",
"date": "2019-03-25",
"time_long": "10:23",
"leaveId": 5,
"leaveLong": 16,
"leaveFrom": "2019-03-15",
"leaveTo": "2019-03-17"
},{
"log_id": 1313,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "07:58",
"check_out": "17:21",
"date": "2019-03-26",
"time_long": "9:23",
"leaveId": 15,
"leaveLong": 8.0,
"leaveFrom": "2019-03-28",
"leaveTo": "2019-03-29"
},
{
"log_id": 1314,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "07:58",
"check_out": "17:21",
"date": "2019-03-26",
"time_long": "9:23",
"leaveId": 5,
"leaveLong": 8.0,
"leaveFrom": "2019-03-28",
"leaveTo": "2019-03-29"
},
{
"log_id": 1315,
"name": "ahmad",
"fname": "Mohammad",
"photo": "images/user_profile//1550473469.jpg",
"title": "Doctor",
"description": null,
"empid": 3,
"check_in": "08:00",
"check_out": "16:00",
"date": "2019-03-27",
"time_long": "8:00",
"leaveId": 5,
"leaveLong": 8.0,
"leaveFrom": "2019-03-28",
"leaveTo": "2019-03-29"
},{
"log_id": 1316,
"name": "Neda Mohammad",
"fname": "Gada Mohammad",
"photo": "images/user_profile//1550473758.jpg",
"title": "Pharmacist",
"description": null,
"empid": 8,
"check_in": "07:36",
"check_out": "17:57",
"date": "2019-03-25",
"time_long": "10:20",
"leaveId": null,
"leaveLong": null,
"leaveFrom": null,
"leaveTo": null
},{
"log_id": 1317,
"name": "Neda Mohammad",
"fname": "Gada Mohammad",
"photo": "images/user_profile//1550473758.jpg",
"title": "Pharmacist",
"description": null,
"empid": 8,
"check_in": "08:00",
"check_out": "16:00",
"date": "2019-03-26",
"time_long": "8:00",
"leaveId": null,
"leaveLong": null,
"leaveFrom": null,
"leaveTo": null
},{
"log_id": 1318,
"name": "Neda Mohammad",
"fname": "Gada Mohammad",
"photo": "images/user_profile//1550473758.jpg",
"title": "Pharmacist",
"description": null,
"empid": 8,
"check_in": "08:00",
"check_out": "16:00",
"date": "2019-03-27",
"time_long": "8:00",
"leaveId": null,
"leaveLong": null,
"leaveFrom": null,
"leaveTo": null
}
]
', true);
$temp = [];
foreach ($arr as $key => $value) {
$temp[$value['empid']][$value['leaveId']][] = $value['leaveLong'];
}
$result = [];
foreach ($temp as $key => $value) {
foreach ($value as $key1 => $value1) {
$result[$key][$key1] = max($value1);
}
}
$result = array_map("array_sum", $result);
print_r($result);
preferences:
26.35 ms | 407 KiB | 5 Q