From 5fba83a8299e95453ac5fc985085406da25cca41 Mon Sep 17 00:00:00 2001 From: Trygve Date: Sat, 17 Feb 2024 19:23:27 +0100 Subject: [PATCH] =?UTF-8?q?Lagde=20en=20l=C3=B8perklasse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_table.php | 91 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/get_table.php b/get_table.php index db087bf..a6437d0 100644 --- a/get_table.php +++ b/get_table.php @@ -1,32 +1,77 @@ id = $id; + $this->name = $name; + for($i = 0; $i<$$GLOBALS['number_of_controls']; $i++) { + array_push($this->splits, 0); + } } - arra - array_search($id, $db); + function set_split($control, $timestamp) { + $this->splits[$control] = $timestamp; + } +} + +//find runner by id in list of Runner objects +function get_runner($runnner_list, int $id) { + for ($i = 0; $i < count($runnner_list); $i++) { + if ($runnner_list[$i] == $id) { + return $runnner_list[$i]; + } + } + return false; +} + +$runners = []; +$csv_runners = file_get_contents("db.csv"); +$csv_runners = str_getcsv($csv_runners, "\n"); +print_r($csv_runners); +for ($i=0; $i < count($csv_runners); $i++) { + $line = str_getcsv($csv_runners[$i]); + array_push($runners, new Runner($line[0], $line[1])); } -for ($i=0; $i < count($db); $i++) { - $runner = str_getcsv($db[$i]); - echo("$runner[0]$runner[1]"); +$timings = file_get_contents("passering.csv"); +$timings = str_getcsv($timings, "\n"); +for ($i=0; $i < count($timings); $i++) { + $line = str_getcsv($timings[$i]); + + $time = DateTime::createFromFormat("Y-m-d\TH:i:sp", $line[2]); + if (!$time) { + //error + continue; + } + + $runner = get_runner($runners, (int)$line[1]); + if (!$runner) { + //error + continue; + } + + $runner->set_split($line[0], $time); +} + +print_r($runners); +for ($i=0; $i < count($runners); $i++) { + $runner = $runners[$i]; + $times = ""; + //for ($i= 0; $i < count($runner[2]); $i++) { + //echo("". $runner[2][$i][1] ."\n"); + //} + + echo("$runner->id$runner->name"); } \ No newline at end of file