When I enter a printf() with a negative parameter for a integer placeholder with a zero padding. The zero padding isn’t applied.
php > printf('%02d', -6);
-6
Am I doing something wrong? Or is it a bug?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Per docs:
paddings is applied on the whole string:
(emphasis mine).
You may want to use the sign specifier if that is acceptable, e.g.: