假设我有一个这样的数组:
$myarray = attr_group => array(
"group_id" => array(
"attr" => array(
[0] => "test1"
[1] => "test2"
[3] => "test1,test2,test3,test4"
[4] => "test1,test5,test6"
)
)
)
如何将“attr”数组中的值分解到不同的行,然后继续使用数组,如果我这样调用它:
$myarray[attr_group][group_id][attr]
我希望我的数组的最终结果看起来像这样:
$myarray = attr_group => array(
"group_id" => array(
"attr" => array(
[0] => "test1"
[1] => "test2"
[3] => "test3"
[4] => "test4"
[5] => "test5"
[6] => "test6"
)
)
)
也许这不可能,但我认为值得发帖!提前谢谢!
答案 0 :(得分:2)
$myarray = array(
"attr_group" => array(
"group_id" => array(
"attr" => array(
0 => "test1",
1 => "test2",
3 => "test1,test2,test3,test4",
4 => "test1,test5,test6"
)
)
)
);
$attr = &$myarray["attr_group"]["group_id"]["attr"];
$attr = array_values(array_unique(explode(",", implode(",", $attr))));
print_r($myarray);