数组到没有索引的子

I have this code, basically take some lines and put in a array in groups of 4

Originally the data comes in this format:

line1
line2
line3
line4
line5
line6
line7
line8

and with this code i pass the lines to array:

$addresses = [];
foreach (preg_split("/((?
)|(
?))/", $nodes) as $line) {
    $temp[] = trim($line);
    if(count($temp) == 4){
        array_push($addresses,[
                    'ADDRESS' => $temp[0],
                    'STREET_NAME' => $temp[1],
                    'TOWN_NAME' => $temp[2],
                    'POST_CODE' => $temp[3]
                ]);
      $temp = [];
  }
}
var_dump(json_encode($addresses,JSON_PRETTY_PRINT));

But the result its not what i want... :

{
  "1": {
      "ADDRESS": "10",
      "STREET_NAME": "TRIQ ID-DAR TA` PULTU",
      "TOWN_NAME": "BIRZEBBUGA",
      "POST_CODE": "BBG 1810"
  },
  "2": {
      "ADDRESS": "12",
      "STREET_NAME": "TRIQ ID-DAR TA` PULTU",
      "TOWN_NAME": "BIRZEBBUGA",
      "POST_CODE": "BBG 1810"
  }
}

And i dont want the index...

i need something like this:

[
{
  "ADDRESS": "10",
  "STREET_NAME": "TRIQ ID-DAR TA` PULTU",
  "TOWN_NAME": "BIRZEBBUGA",
  "POST_CODE": "BBG 1810"
},
{
  "ADDRESS": "12",
  "STREET_NAME": "TRIQ ID-DAR TA` PULTU",
  "TOWN_NAME": "BIRZEBBUGA",
  "POST_CODE": "BBG 1810"
}
]

Any idea about the mistake???

This will create what you are asking for

$nodes = 'line1
line2
line3
line4
line5
line6
line7
line8
';

$addresses = [];
foreach (preg_split("/((?
)|(
?))/", $nodes) as $line) {
    $temp[] = trim($line);
    if(count($temp) == 4){
        $obj = new stdClass();
        $obj->ADDRESS =  $temp[0];
        $obj->STREET_NAME = $temp[1];
        $obj->TOWN_NAME = $temp[2];
        $obj->POST_CODE = $temp[3];

        $addresses[] = $obj;
        $temp = [];
    }
}
var_dump(json_encode($addresses,JSON_PRETTY_PRINT));

Result:

string(266) "[
    {
        "ADDRESS": "line1",
        "STREET_NAME": "line2",
        "TOWN_NAME": "line3",
        "POST_CODE": "line4"
    },
    {
        "ADDRESS": "line5",
        "STREET_NAME": "line6",
        "TOWN_NAME": "line7",
        "POST_CODE": "line8"
    }
]"

But when you look at the data encoded and then decoded back to a PHP datatype, you will still get your objects indexed numerically, as an array has to have an index. This applies to PHP and the javascript equivalent when you get this data to javascript

print_r(json_decode(json_encode($addresses)));

Result

Array
(
    [0] => stdClass Object
        (
            [ADDRESS] => line1
            [STREET_NAME] => line2
            [TOWN_NAME] => line3
            [POST_CODE] => line4
        )

    [1] => stdClass Object
        (
            [ADDRESS] => line5
            [STREET_NAME] => line6
            [TOWN_NAME] => line7
            [POST_CODE] => line8
        )

)