开发者

Allow a specific text string and a range of numbers to be used on PHP promo code script

开发者 https://www.devze.com 2023-04-07 09:14 出处:网络
I have a simple promo code script to apply a discount to an amount before it is passed to Paypal, it works fine but I want to use a number of different codes so I can monitor their performance (all gi

I have a simple promo code script to apply a discount to an amount before it is passed to Paypal, it works fine but I want to use a number of different codes so I can monitor their performance (all give the same discount).

At the moment I have:

if($_POST['promoCode'] == "ABC123")

This allows me to use one code - I would like the letters to remain the same but allow a range of numbers, from maybe 001 to 999.

Looking forward to a reply from you good people, this site has been such a great resource for me over the last twelve months just from reading answers to other people's questions, howev开发者_JAVA百科er I couldn't find one that related to my specific issue.

Thanks in advance!

Scott.


Thanks @M42

if(preg_match('/^ABC(\d{2}[1-9]|\d[1-9]\d|[1-9]\d{2})$/', $_POST['promoCode'])) {}
0

精彩评论

暂无评论...
验证码 换一张
取 消