How does a two-dimensional array add a key to an element?

$res=array (
  0 => 
  array (
    "id" => 10003,
    "rk" => 1,
    "uname" => "1wlt1yb0k69g72t",
    "lt" => 2,
    "rt" => 13,
    "Level" => 2,
  ),
  1 => 
  array (
    "id" => 10004,
    "rk" => 1,
    "uname" => "wm8dd",
    "lt" => 3,
    "rt" => 8,
    "Level" => 3,
  ),
  2 => 
  array (
    "id" => 10005,
    "rk" => 1,
    "uname" => "346p6oc0",
    "lt" => 9,
    "rt" => 12,
    "Level" => 3,
  ),
)

how to add a key-value pair to res [1], location = >"1".

I add res [1] = [location = >"1"] in this way; it directly overrides res [1],

I do this again, res [1] [] = [location = >"1"], and the result is that an array is added. Become

 array (
    "id" => 10004,
    "rk" => 1,
    "uname" => "wm8dd",
    "lt" => 3,
    "rt" => 8,
    "Level" => 3,
    "0"=>array(
      location =>"1",   
    )
  )

it"s a little unscientific. Don"t want that 0. just add a location = >"1" after it.

Php
May.22,2021

res[1]['location'] = 1
Menu