// Handle CSV export if (isset($_POST['export_csv'])) { $groups = json_decode($_POST['export_data'], true); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="sekolah_unique.csv"'); $output = fopen('php://output', 'w'); fputcsv($output, ['Nama Sekolah Standar', 'Jumlah Variasi', 'Variasi Penulisan']); foreach ($groups as $group) { $variations = []; foreach ($group['schools'] as $school) { $variations[] = $school['original']; } fputcsv($output, [ $group['representative'], count($group['schools']), implode('; ', $variations) ]); } fclose($output); exit; }
Identifikasi dan kelompokkan nama sekolah yang sama dengan variasi penulisan berbeda