Loading numbers into a PHP array - unexpected problems

I am trying to define an array of numbers as follows:

$days_pages = array( 'monday' => array(001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020), ... ); 

However, when I do this:

 print_r($days_pages); 

shows

 Array ( [monday] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 0 ************** [8] => 0 ************** [9] => 8 [10] => 9 [11] => 10 [12] => 11 [13] => 12 [14] => 13 [15] => 14 [16] => 15 [17] => 1 ************** [18] => 1 ************** [19] => 16 [20] => 17 

I don’t understand why this is happening - what am I doing wrong?

+4
source share
2 answers

If an invalid digit is specified in octal integer (i.e. 8 or 9), the rest of the number is ignored

as

 <?php var_dump(01090); // 010 octal = 8 decimal ?> 

So

008 , 009

its invalid and be 0

See also in the previous post about octal numbers (a few minutes ago)

arithmetic related php

+7
source

in php integer varaiables accepts octal so you run into this problem.

Show this link first. You can understand.

http://www.ascii.cl/conversion.htm

0
source

Source: https://habr.com/ru/post/1338981/


All Articles