$line) { // if($i == 100) exit(); if($skip != 0) { $skip--; continue; } if ($i == 3316) { $break = true; } if (strpos(strtolower($line), '%') !== false) { if (strpos(strtolower($line), 'ans ') !== false) { preg_match_all('/\d+/', substr($line,1), $matches); $questions[$x]['correctAnswer'] = $matches[0][0]; // <- this looks like eyes. $x++; //NEXT QUESTION. } continue; } if (strpos(strtolower($line), '") continue; } else { $numbers = explode(" ", $line); $questions[$x]['questionNumber'] = substr($numbers[0], 1); } $questionLine = $line; $q=$i; while(!empty($lines[$q+1])) { if(strpos(strtolower($lines[$q+1]), 'Total questions:".$totalCount."
Good questions:".$goodCount."
Bad questions:".$badCount; if($badCount!=0) exit(); $count = $answer = 0; foreach ($questions as $q) { $db = new db(); $db->query("INSERT INTO question(question_time, questiondata_number, questiondata_content, questiondata_image) VALUES(:qTime, :qNumber, :qContent, :qImage)"); $db->bind("qTime", time()); $db->bind("qNumber", $q['questionNumber'] ?: 0); $db->bind("qContent", $q['question']); $db->bind("qImage", $q['image'] ?: ""); $db->execute(); $lastRow = $db->lastInsertId(); $db->kill(); //IS THIS EVEN NEEDED? $row = 1; foreach ($q['answers'] as $a) { $db = new db(); $db->query("INSERT INTO answer(answer_time, answerdata_content, answerdata_question, answerdata_correct) VALUES(:aTime, :aContent, :aQuestion, :aCorrect)"); $db->bind("aTime", time()); $db->bind("aContent", $a); $db->bind("aQuestion", $lastRow); $db->bind("aCorrect", ($q['correctAnswer'] == $row ? "1" : "0")); $db->execute(); $db->kill(); $row++; $answer++; } $db = null; $count++; } echo "Inserted " . $count . " questions and ".$answer." answers.";