$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,
),
)怎樣向res[1]加入一個鍵值對,location =>'1'。我這樣加入 res[1] = [location =>'1'];直接就覆蓋了res[1],我又這樣,res[1][] = [location =>'1'],結(jié)果是加入了一個數(shù)組。變成 array ( 'id' => 10004, 'rk' => 1, 'uname' => 'wm8dd', 'lt' => 3, 'rt' => 8, 'Level' => 3, '0'=>array(
location =>'1',
)
)有點不科學,不要那個 0,直接在后面補一個 location =>'1'。
二維數(shù)組怎樣向某個元素加入鍵值?
萬千封印
2018-09-23 20:42:10