phparrayszerofill

Why php array not support Zerofill arguments


I have an php array having arguments with Zerofill values like..

$a = (00001, 00008, 00009, 00012);

When I am using this array as parameter of a function, then it giving unexpected results, like...

print_r($a); //prints

array  ( [0]=>1  [1]=>0  [2]=>0  [3]=>1 )

Why? and how will we counter this error???


Solution

  • Numbers with leading zero are the octal notation. If you need to prepend numbers by leading zeros you can use string functions.