Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:55:53+00:00 2026-05-24T13:55:53+00:00

I am padding integers for barcodes with leading zeros so they have same number

  • 0

I am padding integers for barcodes with leading zeros so they have same number of characters, for example:

1    -> 00000001 
12   -> 00000012
1044 -> 00001044

00000001 is numeric and when casting to an integer it is 1.

Will this work as expected for all integers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:55:55+00:00Added an answer on May 24, 2026 at 1:55 pm

    Careful, numbers starting with 0 are treated as base 8 in PHP

    >> var_dump(011);
    int(9)
    

    however explicit casting string to int seems to be safe

    >> var_dump((int)'011');
    int(11)
    

    You did not say anything where you’re going to be storing these numbers, but in case it will be a database, here’s some advice regarding datatype:

    Barcode numbers are not (despite the name) numbers. Same goes for fax numbers, social security numbers, etc. You should not store these as numeric data (for example using MySQL’s INT or DECIMAL) datatype. Instead use textual datypes (like CHAR or VARCHAR)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a stylesheet i have: * HTML BODY { padding-right: 0px; padding-left: 0px; padding-bottom:
I have this css: fieldset li { padding-bottom: 0em; } However, it wasn't behaving
I want to stringify a number and add zero-padding, like how printf(%05d) would add
Python's len() and padding functions like string.ljust() are not tabstop-aware, i.e. they treat '\t'
I have a lot of code that performs bitwise operations on unsigned integers. I
I have a textarea in my HTML. I need to get the padding numerical
I have table with schema: test1 (id integer primary key , padding text) (there
Padding is never the same in Firefox and IE, while IE adds padding to
is -negative margin or padding are invalid CSS aaccording to W3C ?
$(a).hover(function(){ $(this).animate({ 'padding-left': '+=10px' }, normal); }, function(){ $(this).animate({ 'padding-left': '-=10px' }, normal); });

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.