I have removed the duplicate items for the following array, by writing:
$outcome['id'] = array_unique($outcome['id'], SORT_REGULAR);
but I'm getting undesirable JSON output
"id": {
"0": {
"id": 947,
"label": "ABCD"
},
"1": {
"id": 2175,
"label": "EFGH"
},
"2": {
"id": 15,
"label": "IJKL"
}
}
instead of the below , which is the desirable JSON output :
"id": [
{
"id": 947,
"label": "ABCD"
},
{
"id": 2175,
"label": "EFGH"
},
{
"id": 15,
"label": "IJKL"
}
]
While debugging on PHPStorm, the result shown was in array format, but on Postman, the result is being transformed to object!