开发者

using array_push($var); with keys

$dizi = array(
"tr" => "Turkey",
"uk" => "United Kingdom",
"us" => "United States"
);

i want to add "br"=>"brasil" to end of the array.

t开发者_开发知识库hanks.


There's nothing to it:

$dizi['br'] = 'brasil';


A syntax construct that's a bit closer to array_push would be:

 $dizi += array("br" => "Brasil");

Note the +=
But for a single addition you should prefer the direct array assignment (as pointed out in the other answers).


you could just do:

$dizi['br'] = "brasil"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜