var_dump() printing the zero number instead of printing the position element

Asked

Viewed 32 times

0

I’m trying to do a simple data output on the screen, I created an array:

$arr1617 = [02,05,06,07,08,09,10,12,13,14,15,20,22,23,25];

After that I used the function var_dump() to generate a data output, but the output leaves with a print error:

array (size=15) 
  0 => int 2
  1 => int 5
  2 => int 6
  3 => int 7 
  **4 => int 0 <--**
  **5 => int 0 <--**
  6 => int 10
  7 => int 12
  8 => int 13
  9 => int 14
  10 => int 15
  11 => int 20
  12 => int 22
  13 => int 23
  14 => int 25

I know removing the number zero the left would solve the problem, but I was curious to know why it occurs.

  • 1

    Numbers with 0 to the left are numbers in octal.

  • So, the bad news is that I have a txt with numbers like this, so I’ll have to turn it into a string, remove the zeros on the left, go back to integer and then put it in the bank.

  • Just turn into string and use intval whether or not to specify base 10 because it is the default basis

  • I’ll try that solution, thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.