我有一个数组
$this->input->post("first_array")={ one two three }
我需要创建一个数组它将包含几个这样的数组
所以我正在做一个' first_array '来保存数组,首先验证它确实是一个数组,然后如果它没有设置,我放一个'未定义'字符串
array(
'fisrt_array' => is_array($this->input->post("first_array")) ? implode(' ',$this->input->post("first_array")) : 'Not defined'
);
如果它被设置了,我内爆保存在$this->input->post("first_array")中的数组
都是正确的,但是我将结果存储为one two three而不是one,two,three
如何保存该格式的数组?
如果我做implode(',',$this->input->post("first_array")
,我会存储 1,2,3,,最后不需要逗号…
implode(',',$this->input->post("first_array")
不能在最后一个元素后加逗号。
这应该对你有用。话虽如此,你在用一种奇怪的方式声明你的数组。
使用$this->input->post['First_Array'] = array('One', 'Two', 'Three');
second_array[] = $this->input->post['First_Array'];