} else { $ids[$keys[trim($q['question'])]] = null; } } $answers_id[$key] = $ids; } //print_r($keys);die(); foreach ($answers0 as $key => $region) { array_shift($region); array_shift($region); $i = 1; foreach ($region as $row) { //print_r($row);die(); $vote = array(); foreach ($answers_id[$key] as $ikey => $id) { $vote[$id] = answer2value($row[$ikey]); } if (isset($parties[$row[$unique_code_column[$key]]])) { $party = $parties[$row[$unique_code_column[$key]]]; $data[$key][] = array('vote' => $vote, 'last_name' => $party['last_name'], 'first_name' => $party['first_name'], 'short_name' => $party['short_name'], 'name' => $party['name'], 'friendly_name' => friendly_url($party['last_name']), 'id' => $i); $i++; } else { //report wrong unique key echo $key . "::" . $row[$unique_code_column[$key]] . "<br/>\n"; } } //print_r($data);die(); //if direcotry not existing, create it $dir = $path . 'volba-prezidenta-cr-2-kolo' . '-2013/'; if (!file_exists($dir)) { mkdir($dir);
unset($a_rev[$rkey]); } else { $codes[trim($r[2])] = true; } } $answers0 = array_reverse($a_rev); array_shift($answers0); $answers = $answers0; //print_r($answers);//die(); foreach ($answers as $answer) { $p_id = unique_code2id($answer[2], $parties, $json); if ($p_id) { foreach ($json as $p) { if ($p->id == $p_id) { for ($i = 101; $i <= 120; $i++) { $p->vote->{$i} = answer2value($answer[q_id2column($i)]); } } } } } //corrections $fcorr = file("https://docs.google.com/spreadsheet/pub?key=0ApmBqWaAzMn_dFRKYVN2bmRuVkJjMDhpTy1FQk5TNkE&single=true&gid=3&output=txt"); $corr0 = array(); foreach ($fcorr as $row) { $corr0[] = explode("\t", $row); } array_shift($corr0); $corr = $corr0; foreach ($corr as $row) { foreach ($json as $p) {