Why php array not support Zerofill arguments

69 Views Asked by At

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???

2

There are 2 best solutions below

0
Timurib On BEST ANSWER

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

0
paranoid On

Try this

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