Question: I'm passing db values using `json _encode()`. Below is the query and all works okay. 

But when I add an additional data to the array I get a number in front of the output data.

```
$sql = "SELECT item, price, availability 
         FROM items 
           WHERE category = :category 
             ORDER BY item DESC";
$stmt= $connect->prepare($sql);
$stmt->execute(array(':category'=>"fruits"));
$rslt = $stmt->fetchAll(PDO::FETCH_ASSOC);

foreach ($rslt as $val){
  $data[] = $val; 
}
$data['additional'] = $someAdditionalData;
echo json_encode($data);

```

Current output:

```
{"0":{"item":"lychee"},"1":{"item":"ornage"},"2": "item":"apple"},"additional":ABC}

```

My question is, how do I get the output without the index numbers (as below)

```
[{"item":"lychee"},{"item":"ornage"},{"item":"apple"},{"additional":"ABC"}]

```

Answer: 
Index numbers were assigned automatically because you have assigned an index yourself called "additional".
In your code try changing

```
$data['additional'] = $someAdditionalData;

```

to

```
$data[] = array('additional' => $someAdditionalDat);

```
Use `array_values()` for your issue:

```
$arr['additional'] = array_values($arr['additional']);
$arr = json_encode($arr);

```

Why? Because you're unsetting array's key without re-ordering it. So after this the only way to keep that in JSON will be encode keys too. After applying `array_values()`, however, you'll get ordered keys (starting from `0`) which can be encoded properly without including keys.