我很难添加到数组的末尾。不知道该怎么做。请帮帮忙。
$person = array(); $person = array("name"=>"tom", "age"=>20, "height"=>180);
如何添加到数组的末尾?我想将“=>120”权重添加到现有数组的末尾。
谢谢
发布于 2011-07-23 09:20:36
由于这是一个关联数组,所以只需执行以下操作:
$person['weight']=120;
对于常规的数字索引数组,可以使用array_push()或$person []= "new value";。
array_push()
$person []= "new value";
https://stackoverflow.com/questions/6797641
相似问题