Good evening, I'm doing 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 available coupons starting with the numbering I reported in 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 wanted to know if you have how my script checks the year of expiration of all coupons and only print those that are not overdue 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 content of db.txt is (are several coupons):
5448285001|05|2018|456
544828500|05|2018|456
544828500175|05|2018|100
54482850017|01|2019|093