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 8052975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:42:31+00:00 2026-06-05T07:42:31+00:00

I am studying about printf,sprintf and i didnt understand few points, if can some

  • 0

I am studying about printf,sprintf and i didnt understand few points, if can some one please help me understand thos points,

At This Link at PHP Manual:

There are explanations are numbered from one to six:

What i didnt understand is: The First and The Second(1(sign specifier), 2(padding specifier)), if can some one please help me with example for thos i will be very thankful.

  • 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-06-05T07:42:33+00:00Added an answer on June 5, 2026 at 7:42 am

    The sign specifier forces a sign, even if it’s positive. So, if you have

    $x = 10;
    $y = -10;
    printf("%+d", $x);
    printf("%+d", $y);
    

    You’ll get:

    +10
    -10
    

    The padding specifier adds left padding so that the output always takes a set number of spaces, which allows you to align a stack of numbers, useful when generating reports with totals, etc.

     $x = 1;
     $y = 10;
     $z = 100;
     printf("%3d\n", $x);
     printf("%3d\n", $y);
     printf("%3d\n", $z);
    

    You’ll get:

       1
      10
     100
    

    If you prefix the padding specifier with a zero, the strings will be zero padded instead of space padded:

     $x = 1;
     $y = 10;
     $z = 100;
     printf("%03d\n", $x);
     printf("%03d\n", $y);
     printf("%03d\n", $z);
    

    Gives:

     001
     010
     100
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am studying about printf and sprintf and I don't understand a few points.
I am trying to understand few things about using dylib and still studying, so
While studying about JMX, I have seen one of the important feature of it
I've been studying this: https://github.com/mikechambers/ExamplesByMesh/blob/master/JavaScript/QuadTree/src/QuadTree.js and I believe I understand the general idea about
I'm studying about windows and DLL stuffs and I have some question about it.
I have been studying as much as I can about the Module Pattern suggested
I am studying for a final and have a few questions about RMI and
I've been studying trees for a few days, and I'm a little confused about
Recently I was studying about parsers including the design patterns used to built one.
I'm studying some basics about informal protocols and real protocols. What confuses me is,

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.