1 回答

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
$phases將生成的代碼應(yīng)用到$dataset然后將其分塊到 中會(huì)更容易$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);
您最終調(diào)用的代碼createSchedule
將是:
foreach ($schedule_batch as $phase) { createSchedule($customer->id, $phase); }
- 1 回答
- 0 關(guān)注
- 142 瀏覽
添加回答
舉報(bào)