Php 在codeigniter上处理1对多关系时,如何将数组从所需部分的数组中拆分出来

Php 在codeigniter上处理1对多关系时,如何将数组从所需部分的数组中拆分出来,php,arrays,codeigniter,split,Php,Arrays,Codeigniter,Split,我的数据来自一个列表,其中gropup\u id是一个带有多个 选择我想要的是在数据表中插入值,而不是gropup\u id我想要将其提取为一个单独的数组,然后将其插入另一个表中 array(11) { ["full_name"]=> string(5) "gjiut" ["username"]=> string(3) "hhj" ["password"]=> string(0) "" ["confirm_password"]=>

我的数据来自一个列表,其中
gropup\u id
是一个带有多个 选择我想要的是在数据表中插入值,而不是
gropup\u id
我想要将其提取为一个单独的数组,然后将其插入另一个表中

    array(11) {
  ["full_name"]=>
  string(5) "gjiut"
  ["username"]=>
  string(3) "hhj"
  ["password"]=>
  string(0) ""
  ["confirm_password"]=>
  string(0) ""
  ["email"]=>
  string(26) "eshopdesigners11@gmail.com"
  ["company_id"]=>
  string(1) "1"
  ["phone"]=>
  string(3) "123"
  ["mobile"]=>
  string(3) "123"
  ["skype_id"]=>
  string(3) "123"
  ["role_id"]=>
  string(1) "1"
  ["gropup_id"]=>
  array(3) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "2"
    [2]=>
    string(1) "3"
  }
}
我的餐桌关系

用户表

id 
user_name
组表

id
group_name
用户组表

user_id
group_id
我试过了,但没用

$post = $this->input->post();

$postArray = $post;
$secondaryarray = array();

foreach ($postArray as $key => $value) {

    if (strpos($value, "gropup_id") != FALSE)
        $secondaryarray[] = $value;

    unset($post[$key]);
}

gropup_id是一个键,而不是postArray中的值

而不是

if (strpos($value, "gropup_id") != FALSE)


gropup_id是一个键,而不是postArray中的值

而不是

if (strpos($value, "gropup_id") != FALSE)


完善的代码

$post = $this->input->post();


        $postArray = $post;
        $secondaryarray = array();

        foreach ($postArray as $key => $value) {

            if ($key == "gropup_id")
                $secondaryarray = $value;

            unset($postArray['gropup_id']);
        }

完善的代码

$post = $this->input->post();


        $postArray = $post;
        $secondaryarray = array();

        foreach ($postArray as $key => $value) {

            if ($key == "gropup_id")
                $secondaryarray = $value;

            unset($postArray['gropup_id']);
        }