-1
foreach
의 값을 하나의 변수에 저장하려고합니다. 하지만 난 그것을 얻이 수없는 것 : 내가 얻을PHP foreach : 각 루프 결과를 변수에 넣습니다.
foreach ($chunks as $key) {
// Get the Excel template path
$path = storage_path('/app/excel/331-3-17 72AN - 21.3 - Ст. 20.xlsx');
// Load the excel template file
Excel::load($path, function($reader) use (&$key) {
// Load the Excel sheet
$objExcel = $reader->getExcel();
$sheet = $objExcel->getSheet(0);
foreach ($key as $row) {
$welds = $row->weld;
$string .= $welds.',';
}
$sheet->getCell('B25')->setValue($string);
})
// Set filename & store it
->setFilename("331-3-17 72AN - 21.3 - Ст. 20 " . date("d.m.y").'-'.mt_rand())
->store('xlsx', storage_path('/app/exports/21.3 - 2.5 - Ст20 '.date('m-d-Y')));
}
결과는 다음과 같습니다 하나 개의 문자열이
КСС1814.
예상 결과 :
КСС1810, КСС1811, КСС1812, КСС1813, КСС1814
외부 루프가있는 경우 해당 코드도 표시 –
업데이트 총 코드 – kranthi
$ string은 (는) 어디에서 시작 했습니까? – laiju