function get_hotspot_objects($quest) { $hotspot_ids = array(); $hotspots = array(); $hotspot_xml_objects = array(); $missions_array = array(); // Get the missions if ($quest->exists) { $missions = $quest->get_missions(); foreach ($missions as $mission) { array_push($missions_array, $mission->id); } foreach ($missions_array as $mission_id) { $current_mission = new mission($mission_id); // Get the hotspot ids from the current mission, add them to the array $current_hotspots = $current_mission->get_hotspots(); foreach ($current_hotspots as $ch) { array_push($hotspot_ids, $ch->id); } } foreach ($hotspot_ids as $hid) { $new_hotspot = new hotspot($hid); array_push($hotspots, $new_hotspot); } // Turn the xml from each of the hotspots into an xml object foreach ($hotspots as $xml) { $new_xml_obj = simplexml_load_string($xml->get_xml()); array_push($hotspot_xml_objects, $new_xml_obj); } } return $hotspot_xml_objects; }
curl_setopt($ch, CURLOPT_HEADER, 0); // 헤더 출력 여부 curl_setopt($ch, CURLOPT_POST, 1); // Post Get 접속 여부 curl_setopt($ch, CURLOPT_POSTFIELDS, "var1=str1&var2=str2"); // Post 값 Get 방식처럼적는다. curl_setopt($ch, CURLOPT_TIMEOUT, 30); // TimeOut 값 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 결과값을 받을것인지 $this->buffer = curl_exec($ch); curl_close($ch); } function result() { //한자 preg_match_all("/\\<span\\>\\[(.*)\\]/", $this->buffer, $match); //히라가나 preg_match_all("/event\\)\\;\"\\>(.*)\\[/", $this->buffer, $matches); for ($i = 0; $i < count($match[1]); $i++) { static $tmp = 0; $voca[$tmp]['v1'] = $matches[1][$i]; $voca[$tmp]['v2'] = $match[1][$i]; $tmp++; } print_r($voca); } } $exam = new mission(); $exam->get_content("http://jpdic.naver.com/jlpt/level-1/parts-0/p1.nhn"); $exam->result();
<!DOCTYPE html> <html> <head> <meta charset = 'utf-8' /> </head> <body> <?php require_once 'reviser.php'; require_once 'mission.php'; $exam = new mission(); $words = $exam->get_voca(); $Excel = new Excel_Reviser(); //Charset設定 $Excel->setInternalCharset('utf-8'); //첫번 째 인자값은 sheet번호 //두번 째 인자값은 세로(1~~~)열 //세번 째 인가값은 가로(A~~~)행 //0부터 시작 // 1枚目の(B,1) $Excel->addString(0, 0, 1, 'No'); // 1枚目の(C,1) $Excel->addString(0, 0, 2, '히라가나'); // 1枚目の(D,1) $Excel->addString(0, 0, 3, '한자'); // 1枚目の(E,1) $Excel->addString(0, 0, 4, '품사'); // 1枚目の(F,1) $Excel->addString(0, 0, 5, '해석'); //配列のインデックスが73から始め、配列の数だけの繰り返し for ($i = 73; $i < count($words); $i++) {