increment - Incrementing values larger than 2147483647 in PHP -


basically i'm working on card management system in particular module has job of creating bulk cards sequential. these cards 19 digits long , because these cards have monetary value need store entire card value. odd thing system has no trouble managing visa card number incrementing , 16 digits long. i'm assuming last 3 digits breaking function have no idea how on earth handle i've never had deal such large values before.

$seqarray = array(); for($i = $_post['startcardnumber']; $i <= $_post['endcardnumber']; $i++) {     $i = sprintf('%0.0f',$i);     if(strlen($i) < $count) { $i = str_pad($i, $count, '0', str_pad_left); }     array_push($seqarray, $i); } 

any appreciated.

thanks fluffeh found out bc math functions needed. below new loop i'm using calculate , increment card numbers.

$seqarray = array(); for($s = $_post['startcardnumber'], $e = $_post['endcardnumber'];bccomp($s,$e) != 1; $s = bcadd($s, 1)) {     if(strlen($s) < $count) { $s = str_pad($s, $count, '0', str_pad_left); }     array_push($seqarray, $s); } 

the bc math library might little tedious work with, handle numbers in values need ease.

the downside can't use simple things operators expected:

for example, addition done following - using bcadd() function:

<?php  $a = '1.234'; $b = '5';  echo bcadd($a, $b);     // 6 echo bcadd($a, $b, 4);  // 6.2340  ?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -