在php中增加foreach的响应



从file_get_contents函数获取数据时,将数据添加到数组中。然后用XLSXWriter将数据添加到excel中。看起来对foreach的响应被限制为100。这是否可能改变,使其成为一个更大的金额?

$data = file_get_contents("/home/user/testfile.json");
$json_obj = json_decode($data, true);

foreach ($json_obj['items'] as $order) {

$ordrenr =  $order['id'];
$fornavn= $order['billingPerson']['firstName'];
$etternavn= $order['billingPerson']['lastName'];
$adresse = $order['billingPerson']['street'];
$postnr = $order['billingPerson']['postalCode'];
$sted = $order['billingPerson']['city'];
$mobil = $order['billingPerson']['phone'];
$epost = $order['email'];
$subtotal = $order['total'];
$bestilt = $order['createDate'];
$betalingstype = $order['paymentMethod'];
$fakturanr = $order['invoices'][0]['id'];
$fakturalink = $order['invoices'][0] ['link'];

$header = ['Ordrenr' => 'string',
'Fornavn' => 'string',
'Etternavn' => 'string',
'Adresse' => 'string',
'Postnr' => 'string',
'Sted' => 'string',
'Mobil' => 'string',
'Epost' => 'string',
'Bestilt' => 'string',
'OrdreSum Inkl MVA' => 'string',
'Betalingtype' => 'string',
'Faktura nr' => 'string',
'Ordreskjema' => 'string' ]; 

$rows[] = [$ordrenr, $fornavn, $etternavn, $adresse , $postnr, $sted , $mobil, $epost, $bestilt, $subtotal, $betalingstype , $fakturanr, $fakturalink];
}
$structure = "/home/user/testfolder/";
if (!file_exists ($structure))
{
mkdir($structure, 0777, true);
}

$writer = new XLSXWriter(); 
$writer->setAuthor('Author'); 
$writer->writeSheet($rows, 'SHEETNAME', $header);
$writer->writeToFile("/home/user/testfolder/"  . "April_".  "$from". "_data.xlsx"  );
$header = ['Ordrenr' => 'string',
'Fornavn' => 'string',
'Etternavn' => 'string',
'Adresse' => 'string',
'Postnr' => 'string',
'Sted' => 'string',
'Mobil' => 'string',
'Epost' => 'string',
'Bestilt' => 'string',
'OrdreSum Inkl MVA' => 'string',
'Betalingtype' => 'string',
'Faktura nr' => 'string',
'Ordreskjema' => 'string' ]; 

首先,上述代码应该从foreach循环中排除。其次,您是否得到执行时间限制超出错误或其他问题?如果是,那么你可以通过设置max_execution来增加限制。

ini_set('max_execution_time', '0');

最新更新