I am trying to convert 08 and 09 to 8 and 9 respectively, but they are not getting converted.
I tried 08+0 , 09+0 but the result I obtained in both the cases is 0.
The above method is working for 01 to 07 and I am obtaining results as 1,2,...7, but not for 08 and 09. Please help me out.
daniel36
-7
Light Poster
Recommended Answers
Jump to PostIf you precede an integer with a zero, it is assumed to be in octal notation. If you need an integer outputted with a leading zero, use
sprintf()
.
Jump to Postcast it to integer:
$var = "09";
echo (int)$var;or
number_format($var)
All 6 Replies
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
dorco
12
Light Poster
daniel36
-7
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
dorco
12
Light Poster
masterjiraya
-3
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.