3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "status": "success", "code": 200, "data": { "total": 5003, "max_score": null, "hits": [ { "_index": "latestlogs", "_type": "logs", "user_id": "rgertg4356ert", "_score": 13.127081, "_source": { "allcaller_id": "453454534", "source": "1", "company_id": "353454355", "caller_number_raw": "4353445345", "_cm": "", "caller_number": "+34534545", "country": "91", "state": "IN", "synced_time": 1554898407, "start_time": 1554898251, "_ms": 1554898251000, "seconds": 43851, "end_time": 1554898366, "duration": "00:01:55", "_drm": 1.92, "type": 1, "event": 1, "filename": "fgdfg.mp3", "fileurl": "google.com/mp3", "_ns": "0", "status": 1, "department_name": "During Office", "department_id": "r43rfdt43refd", "additional_parameters": [ { "ky": "unique_id", "vl": "d2.1554898249.1594961" }, { "ky": "is_starred", "vl": "0" }, { "ky": "view_type", "vl": "2" }, { "ky": "is_commented", "vl": "0" }, { "ky": "is_archived", "vl": "0" }, { "ky": "internal_flag", "vl": "1" } ], "comments": [ ], "log_details": [ { "received_by": [ { "user_id": "43535rfret", "name": "Peter", "email": "", "extension": "13", "contact_number_raw": "53534543", "contact_number": "+343243535" } ], "transfered_to": [ ], "status": "1", "start_time": 1554898284, "end_time": 1554898366, "duration": "00:01:22", "action": "received" } ], "_us": [ { "ky": "dfsdf", "vl": "received" } ], "_tc": [ { "ye": "dsfsdf", "yf": 82 } ], "_ri": "" } } ] } }'; $x = json_decode($json, true); foreach ($x['data']['hits'] as $key => $val) { $receivedBy = $val['_source']['log_details'][0]['received_by'][0]; var_dump($receivedBy); }
Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
array(6) { ["user_id"]=> string(10) "43535rfret" ["name"]=> string(5) "Peter" ["email"]=> string(0) "" ["extension"]=> string(2) "13" ["contact_number_raw"]=> string(8) "53534543" ["contact_number"]=> string(10) "+343243535" }

preferences:
149.27 ms | 408 KiB | 5 Q