我想在一个键中合并两个键的两个值。 该数组如下所示:
[PromotionIds] => Array (
[PromotionId] => Array (
[0] => Amazon PLCC Free-Financing Universal Merchant MP-rachmit-1507891499711
[1] => Amazon PLCC Free-Financing Universal Merchant Script-1507895115492
)
)
但我想将[0]
和[1]
密钥合并到密钥[PromotionID]
中:
[PromotionIds] => Array (
[PromotionId] => Amazon PLCC Free-Financing Universal Merchant MP-rachmit-1507891499711,Amazon PLCC Free-Financing Universal Merchant Script-1507895115492
)
答案 0 :(得分:0)
我认为implode
方法可以帮助您:
<?php
$a = [
123 => [
"String1",
"String2"
],
234 => [
"String3",
"String4",
"String5"
]
];
foreach($a as $promotionId => $items) {
$a[$promotionId] = implode($items, ',');
}
var_dump($a);
//array(2) {
// [123] =>
// string(15) "String1,String2"
// [234] =>
// string(23) "String3,String4,String5"
//}
答案 1 :(得分:0)
试试这种方式
estimator.train
结果如您所愿。