помогите правильно создать массив объектов бьюсь второй день не могу сообразить как сделать правильно.
Нужен массив вида :
{
"number":1,
"comment":"order",
"weight":82000,
"length":60,
"width":80,
"height":40,
"items":[{
"ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":100,
"weight":13666,
"amount":1
}]},
{"number":2,
"comment":"order",
"weight":82000,
"length":60,
"width":80,
"height":40,
"items":[{
"ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":100,
"weight":13666,
"amount":1
}]},
{"number":3,
"comment":"order",
"weight":82000,
"length":60,
"width":80,
"height":40,
"items":[{
"ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":100,
"weight":13666,
"amount":1
}]}]
пытаюсь сделать следующим образом:
function getBoxData ($parameters, $i, $allWeight, $weight, $cost){
return [[
"number"=> $i,
"comment"=>'order',
"weight"=>$allWeight,
"length"=>$parameters['box']['a'],
"width"=>$parameters['box']['b'],
"height"=>$parameters['box']['c'],
"items"=>[[
"ware_key"=>'001',
"payment"=>["value"=>0],
"name"=>'tovar',
"cost"=>$cost,
"weight"=> $weight,
"amount"=>1
]],
]];
}
function getMassiveBox (){
$parameters[box] = array(
a=>40,
b=>40,
c=>40
);
$parameters['nbb']=2;
$i=1;
$allWeight=6000;
$weightBox=1000;
$costbox=100;
$weightBBox=2000;
$costbbox==200;
$boxData = getBoxData ($parameters,$i,$allWeight,$weightBox,$costbox);
if ($parameters['nbb']!=0) {
for ($i=2; $i<=$parameters['nbb']+2; $i++){
$bboxData = getBoxData ($parameters,$i,$allWeight,$weightBBox,$costbbox);
array_push($boxData, $bboxData);
}
}
var_dump ('$boxData',json_encode($boxData));
}
получаю ответ :
"{"number":1,
"comment":"order",
"weight":6000,
"length":40,
"width":40,
"height":40,
"items":[{
"ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":100,
"weight":1000,
"amount":1
}],
"0":
{"number":2,
"comment":"order",
"weight":6000,
"length":40,
"width":40,
"height":40,
"items":[{
"ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":null,
"weight":2000,
"amount":1
}]},
"1":
{"number":3,
"comment":"order",
"weight":6000,
"length":40,
"width":40,
"height":40,
"items":[{"
ware_key":"001",
"payment":{"value":0},
"name":"tovar",
"cost":null,
"weight":2000,
"amount":1
}]}}"
Как избавиться от нумерации объектов?