$value) { /* Override key name for questions */ if ($value === "Verified") { $is_question = false; } if (strstr($value, "candidate photo")) $value = "Photo"; if (strstr($value, "In which Local Government Area")) $value = "LGA"; if (strstr($value, "In which Ward")) $value = "Ward"; if (strstr($value, "Political Party")) $value = "Party"; if ($value === "Pledge") { if (strstr($data[$key], "I pledge")) $data[$key] = "Yes"; else $data[$key] = "No"; } if ($is_question) { $candidate['q'.$question_no++] = $data[$key]; } else { $candidate[$value] = $data[$key]; } if ($value === "Pledge") { $is_question = true; } } $candidate_data[] = $candidate; } fclose($handle); } else { error_log('Error opening candidates file'); exit(1); } return $candidate_data; }