I wrote an API call that should return and sort values from database in code I provided.

Anway it works, but not in a way that it should.

```
$result = array();
foreach ($myResults as $myResult => $label) {
    $result['id'][$myResult] =  $label["id"];
    $result['name'][$myResult] =  $label["name"];
    $result['totalCollected'][$myResult] =  $label["totalCollected"];
}

return $result;

```

So, this is my code and it returns..

```
"data": {
    "id": [
        1,
        2
    ],
    "name": [
        "Name 1",
        "Name 2"
    ],
    "totalCollected": [
        2500,
        2000
    ]
},

```

I want to iterate an array to look like this..

```
 [
    {
        "id": 1,
        "name": Name 1,
        "value": 2500,
    },
    {
        "id": 2,
        "name": Name 2,
        "value": 2000,
    }
 ]

```