Reputation: 1261
I'd like an incremented $max_id
to be returned.
Seems that the following script doesn't work:
<?php
$max_id = 656886639189471232;
$max_id = $max_id+1;
$max_id = number_format($max_id, 0, '', '');
var_dump($max_id);
?>
Needed 656886639189471233
Upvotes: 0
Views: 158
Reputation: 720
Try this:
<?php
$a = "656886639189471232";
$b = "1";
echo bcadd($b, $a,0);
?>
If your input data are integers you can convert $a
and $b
to string with:
$var=5;
$tostring = strval($var);
echo var_dump($tostring);
Upvotes: 2
Reputation: 1203
The problem is number_format is made for float.
You can have details on this other post Why is my number value changing using number_format()?
Upvotes: 0
Reputation: 162
Remove the following line:
$max_id = number_format($max_id, 0, '', '');
The following works fine:
$max_id = 656886639189471232;
$max_id = $max_id+1;
var_dump($max_id);
Upvotes: -1