function importFile($file_name) { global $startWith; $data = file_get_contents($file_name); $json = json_decode($data, true); info("[---------------- starting with {$startWith} ----------------]"); for ($i = $startWith; $i < count($json); $i++) { $candidate = $json[$i]; if ($candidate["EXPLICATIE"]) { continue; } $num = (double) $candidate["college"]; $college_name = ucwords(strtolower("{$candidate["room"]}{$num} {$candidate["county"]}")); addCandidateToCollege($college_name, $candidate["name"], $candidate["party"], $candidate["source"]); $startWith = $i; } }
function importFile($file_name, $college_letter_code) { global $startWith; $data = file_get_contents($file_name); $json = json_decode($data, true); info("[---------------- starting with {$startWith} ----------------]"); for ($i = $startWith; $i < count($json); $i++) { $college = $json[$i]; $num = (double) $college["coldep"] > 0 ? (double) $college["coldep"] : (double) $college["colsen"]; $college_name = ucwords(strtolower("{$college_letter_code}{$num} {$college["jud_lbl"]}")); info("[---------------------------------------------------]"); info("[{$i}. {$college_name}]"); $parts = extractNameAndParty($college["USL"]); addCandidateToCollege($college_name, $parts[0], $parts[1]); $parts = extractNameAndParty($college["ARD"]); addCandidateToCollege($college_name, $parts[0], $parts[1]); addCandidateToCollege($college_name, $college["PP_DD"], "PP_DD"); addCandidateToCollege($college_name, $college["UDMR"], "UDMR"); if ($college_letter_code == "D") { $others = explode(", ", $college["Alti_Candi"]); } else { $others = explode(", ", $college["Alti_candi"]); } foreach ($others as $other_candidate) { $other_candidate = trim($other_candidate); if ($other_candidate == "") { continue; } $parts = extractNameAndParty($other_candidate); addCandidateToCollege($college_name, $parts[0], $parts[1]); } $startWith = $i; } }