Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to increment a number after concatinating it with a date function in php

function generateId($existingIds) {
    $currentDate = date('Ymd');

    $id = 1;

    while (in_array($currentDate . sprintf('%02d', $id),$existingIds)) {
        $id++;
    }

    return $currentDate . sprintf('%02d', $id);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #increment #number #concatinating #date #function #php
ADD COMMENT
Topic
Name
5+3 =