4

I'm trying to define an array of numbers like this:

$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:

print_r($days_pages);

it 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 dont understand why this would be happening - what am I doing wrong?

1
  • Did you mean to use octal there? Commented Feb 9, 2011 at 6:37

2 Answers 2

7

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

like

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

so

008, 009

its not valid and be 0

look also in previous post on octal numbers (a few minutes ago)

related to php arithmetic

Sign up to request clarification or add additional context in comments.

3 Comments

damn - that's a good observation! so i cant use the numbers as they are...!
can u make an array with numbers that omit there leading zero
yup - did exactly that... @jacob - no i didnt mean to, but was just replicating some content from elsewhere... (without thinking!)
0

in php integer varaiables take octal that hwy you face this problem.

Show this link first.you can understand.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.