I am trying to instert an integer into a form. Users are asked to input there promo number which is in the format 12.2-9999. I only want to insert 9999 into the column in my database but I am getting -9999 in the columns. I am not sure if I should use preg_replace or something else here?
Just use explode()
, like so:
list( , $promo) = explode( '-', '12.2-9999');
Now $promo
will contain 9999
.
以下正则表达式将检查最后一个-
并将数字捕获到末尾(根据示例为9999
):
/-(\d+)$/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.