fork download
  1. <?php
  2.  
  3. $textFileString = '2017-03-03, 1;
  4. 2017-03-03, 2;
  5. 2017-03-03, 3;
  6. 2017-03-03, 4;
  7. 2017-03-03, 5';
  8. $currentDate = '2017-03-03';
  9. if (preg_match("/(\d{4}-\d{1,2}-\d{1,2}),\s(\d)\z/", $textFileString, $entryArray)) {
  10. if ($entryArray[1] == $currentDate) { //$currentDate's value comes from the post request
  11. $bookingNumber = $entryArray[2]+1;
  12. } else {
  13. $bookingNumber = 1;
  14. }
  15.  
  16. }
  17. echo $bookingNumber;
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
6