Last active
October 13, 2015 00:28
-
-
Save resmo/4110603 to your computer and use it in GitHub Desktop.
next_bind_serial builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class OutOfSerialsException extends Exception {} | |
function next_bind_serial($serial) { | |
$today = date("Ymd"); | |
for ($i = 0; $i < 100; $i++) { | |
$new_serial = $today.sprintf("%02d",$i); | |
if ($serial < $new_serial) { | |
return $new_serial; | |
} | |
} | |
throw new OutOfSerialsException; | |
} | |
$serial = "2012111902"; | |
echo next_bind_serial($serial); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment