0
Good evening, I’m making a script that pulls the coupon number for my clients
$cu = $_GET['bin'];
$bin = substr($cu, 0, 6);
$file = 'db.txt';
$searchfor = $bin;
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if (preg_match_all($pattern, $contents, $matches)) {
$encontrada = implode("<br>", $matches[0]);
}
echo $encontrada;
In this simple code it returns me all the coupons available starting with the numbering I reported on GET:
http://localhost/cli.php?bin=544828
544828|01|2019|018
544829|09|2018|775
544825|05|2018|036
544822|10|2014|001
544828|11|18|279
544828|07|20|976
544828|08|20|725
544828|04|21|201
I was wondering if my script can check the expiration year of all coupons and just print the ones that are not expired on the screen. Type:
if(... < 2018 or ... < 18) {
Não printa na tela
}
Thank you
var_dump($matches[0]); //me retorna
array(125) { [0]=> string(29) "547874|09|2016|156 " [1]=> string(29) "5478749|10|2016|084 " [2]=> string(29) "547874902|12|2016|462 " [3]=> string(29) "54787490|05|2016|895 " [4]=> string(29) //e muito mais cupons...
The contents of db.txt are (several coupons):
5448285001|05|2018|456
544828500|05|2018|456
544828500175|05|2018|100
54482850017|01|2019|093
What is the column of the year? the third ? What is the information on
'db.txt'
? What givesvar_dump($matches[0]);
within theif
?– Isac
The column of the year is the third, on the other doubts I will change my topic.
– user113606
Ready friend :) If you can take a look there
– user113606
But those years like
18
sane2018
? Coupons that are not expired would be those that have year and month less or equal to the current ?– Isac