我有一个像这样的数组:
$aSample = [
'productName' => [
'sample',
'sample2'
],
'productNumber' => [
'numberOne',
'numberTwo'
]
];
如何使该数组看起来像这样:
productName=sample,sample2&productNumber=numberOne,numberTwo
谢谢您的帮助!
我认为这会起作用
$aSample = [
'productName' => [
'sample',
'sample2'
],
'productNumber' => [
'numberOne',
'numberTwo'
]
];
$array = [];
foreach($aSample as $key=>$item) {
$arr = $key.'='.implode(',',$item);
array_push($array,$arr);
}
echo implode('&',$array);