我有以下的数组结构:
[prod_prop] => Array
(
[45375] => Array
(
[0] => 129|3|Mid-length
)
[45374] => Array
(
[0] => 130|3|Long
[1] => 129|3|Mid-length
)
[45373] => Array
(
[0] => 131|3|
[1] => 130|3|Long
[2] => 129|3|Mid-length
)
)
我希望能循环遍历每个父级数字,并输出第二层数组的第一部分的逗号分隔字符串。所以,如何为每个数字获取一个分隔值,使得期望结果如下:
45375 -> 返回129
45374 -> 返回130, 129
45373 -> 返回131, 130, 129
这是我目前的代码,它返回逗号分隔数组中的所有内容,而不是我要的东西:
foreach($_POST['prod_prop'] AS $prop_ids) {
$list = implode(",",$prop_ids);
echo $list;
}
返回结果: 131|3|131|3|,130|3|长131|3|,130|3|长,129|3|中等长度131|3|,130|3|长,129|3|中等长度