3f641c2d3e2539a81fc6cdbe9bd87b7fad814fd0
3 if (!isset($_POST["players"]))
5 // Retrieve all players
6 $handle = fopen("../joueurs.csv", "r");
9 $data = fgetcsv($handle); //skip header
10 while (($data = fgetcsv($handle)) !== FALSE)
12 $players[$row] = array(
15 "score" => count($data)>=3 ? $data[2] : 0,
16 "pdt" => count($data)>=4 ? $data[3] : 0,
17 "available" => count($data)>=5 ? $data[4] : 1,
22 echo json_encode($players);
26 // Write header + all players
27 $handle = fopen("../joueurs.csv", "w");
28 fputcsv($handle, ["prenom","nom","score","pdt","present"]);
29 $players = json_decode($_POST["players"]);
30 foreach ($players as $p)
31 fputcsv($handle, (array)$p);