Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

 2 Answer(s)

  • As you mention you need a number which starts from 000 like but a integer variable always ignore the number starts from 0, so first thing you need to hold it as a string may be. Generating incremented number is not a big thing you can use database table or a static integer variable which will give you a number +1 to its previous value.

    Now suppose you have a table handling the incremented integer value, which will give you 1 then 2 then 3 and so on whenever you call that function or you can create sequence in db.

    int $numericId = getIdFromDB(); // this will give you previous id +1

    Suppose you have 1 in variable $numericId. Now create a function getFiveDigitId( $numericId) which will return the string of five digit:

     function getFiveDigitId( $numericId){
      $id = $numericId/100000; // will give you 0.00001
      $strId = strVal($id); // convert to string 
      if(startsWith($strId, "0.")){
       return substr($strId, 1);
      return $numericId;
Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: