doujiene2845 2017-03-10 06:10
浏览 60
已采纳

如何将值附加到PHP中的数组中的数组? [重复]

This question already has an answer here:

Given this PHP array:

$options['systems'] = array(1, 2, 3)

How would I append the value 4 to the $systems array within the $options array?

</div>
  • 写回答

2条回答 默认 最新

  • dongzhenju3015 2017-03-10 06:16
    关注

    You could use array_push to push additional items like so:

    array_push($options['systems'], 4);
    

    Or the shorthand version:

    $options['systems'][] = 4;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?