1 回答
TA贡献1821条经验 获得超6个赞
$phases将生成的代码应用到$dataset然后将其分块到 中会更容易$schedule_batch:
$phases = [];
foreach ($dataset as $data) {
$phases[] = [
'end_date' => $data["end_date"],
'transfer_data' => [
'amount_percent' => 20,
'destination' => 10],
'proration_behavior' => 'none',
'plans' => [
[
'price_data' => [
'unit_amount' => $data["unit_amount"],
'currency' => 'usd',
'product' => $data["product"],
'recurring' => [
'interval' => 'month',
],
],
],
],
];
}
$schedule_batch = array_chunk($phases, 2);
$numberofbatches = count($schedule_batch);
您最终调用的代码createSchedule
将是:
foreach ($schedule_batch as $phase) { createSchedule($customer->id, $phase); }
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报