_extractRangLimitesEtNbPostesDispo.php_ 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. require_once "libs/fnMain.php";
  3. // Page permettant d'extraire le nombre de postes proposés, choisis, laissés libres, leur rang limite
  4. function main(string $html)
  5. {
  6. global $_SETTINGS;
  7. $regex = '#norm(\d+)".+\n(\d+)<span>dispo : (\d{1,5})<br>[\s\S]+placé : (\d{1,5})<br>[\s\S]+offre : (\d{1,5})<hr>#U';
  8. $matches = [];
  9. preg_match_all($regex, $html, $matches, PREG_SET_ORDER);
  10. // var_dump($matches);die();
  11. $specialitySourceDatasetAbrev = getCsvToArrayKeyValue($_SETTINGS["datasetFolder"]."/liste_specialites_abrev.csv");
  12. $citySourceDatasetAbrev = getCsvToArrayKeyValue($_SETTINGS["datasetFolder"]."/raphael/liste_villes_abrev_raph.csv");
  13. // Génération CSV
  14. $strResult = "Session,Spe,CHU,Postes,Offres_Norm,Dispo,Rang_Limite,Offres_CESP<br>";
  15. foreach ($matches as $match) {
  16. // On split l'id du choix en identifiant
  17. $cityId = substr($match[1], 1, 2);
  18. $speId = substr($match[1], 3, 3);
  19. // On insère les données
  20. $strResult .= "ecn2017,"; // CHANGER LIGNE ICI POUR ANNEE
  21. $strResult .= $specialitySourceDatasetAbrev[$speId] . ",";
  22. $strResult .= $citySourceDatasetAbrev[$cityId]. ",";
  23. $strResult .= $match[4] . ",";
  24. $strResult .= $match[5] . ",";
  25. $strResult .= $match[3] . ",";
  26. $strResult .= $match[2] . ",";
  27. $strResult .= "0<br>";
  28. }
  29. echo $strResult;
  30. }
  31. $html = <<< 'HERE'
  32. // Insérer code HTML page "limites" du CNG
  33. HERE;
  34. main($html);