<?php
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, JSON_PRETTY_PRINT));
}
getMassiveBox();