sheet('Products') ->withHeaderRow(1) ->toArray(['skip_empty_rows' => true]); $errors = []; foreach ($rows as $index => $row) { $excelRow = $index + 2; if (trim((string) ($row['SKU'] ?? '')) === '') { $errors[$excelRow][] = 'SKU is required.'; } if (!is_numeric($row['Price'] ?? null) || (float) $row['Price'] < 0) { $errors[$excelRow][] = 'Price must be a non-negative number.'; } } print_r($errors); } catch (MnbExcelException $error) { fwrite(STDERR, $error->getMessage() . PHP_EOL); exit(1); }