Các công cụ hỗ trợ online

Các vấn đề liên quan đến Joomla và Joomla extension.
Post Reply
User avatar
support
Posts: 285
Joined: 05 Jan 2017, 09:34

Các công cụ hỗ trợ online

Post by support » 11 Feb 2018, 14:55

Các hàm PHP test online:
Json decode: http://freeonlinetools24.com/json-decode
Preg_match: https://www.functions-online.com/preg_match.html

Code: Select all

<?php
ini_set('max_execution_time', 18000);
// set the default timezone to use. Available since PHP 5.1
date_default_timezone_set("Asia/Bangkok");

echo date(DATE_RFC2822); echo "<br /> Start <br />";
$folder = './data';
$nummm = 0;
if ($handle = opendir($folder)) {
    while (false !== ($fileName = readdir($handle))) {
		$stored = 'Score-grade-4-8-ok.txt';
		if ($fileName != "." && $fileName != ".." && $fileName != "bad"){
			if($json = file_get_contents($folder.'/'.$fileName, FILE_USE_INCLUDE_PATH)){
				$id = str_replace(".txt","",$fileName);
				$filelink = "./data/".$id.'.txt';
				$record = @json_decode($json, true);
				if($record){
					for ($i = 0; $i < 2; $i++){
						$result = @$record["result"][0]["takes"][$i]['contest_code']; //contest_code, score
						if(isset($result) && $result == 'EC2018') {
							$score = $record["result"][0]["takes"][$i]['score'];
							$grade = $record["result"][0]["takes"][$i]["exam_shift"]["exam_shift_grade"];
							$content = "$id\t$grade\t$score";
							file_put_contents($stored,$content . PHP_EOL, FILE_APPEND);
							//$nummm++;
							break;
						}
					}
				}					
			}
		}
		//if($nummm == 10) break;
    }
    closedir($handle);
}
echo "Finish<br />";
echo date(DATE_RFC2822);
echo "<br />Done";
?>


Post Reply