推项目在PHP关联数组 [英] Push item to associative array in PHP
本文介绍了推项目在PHP关联数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在试图将项目推到一个关联数组是这样的:
$ new_input ['名'] =阵列(
'型'=> '文本',
标签= GT; '名字',
'秀'=>真正,
必要= GT;真正
);
array_push($选项['输入'],$ new_input);
然而,代替名称作为密钥增加了许多。是否有另一种方式做到这一点?
解决方案
$选项['输入'] ['名'] = $ new_input ['名'];
I've been trying to push an item to an associative array like this:
$new_input['name'] = array(
'type' => 'text',
'label' => 'First name',
'show' => true,
'required' => true
);
array_push($options['inputs'], $new_input);
However, instead of 'name' as the key in adds a number. Is there another way to do it?
解决方案
$options['inputs']['name'] = $new_input['name'];
这篇关于推项目在PHP关联数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文