Ne Kr
Ne Kr

Reputation: 208

correct notation of three dimensional array

I am a little bit in doubt, if this is a correct notation in a three dimensional array. This is just a part of my code, but when I run the code I get an error, where it says I need ')'.

$property = array(
    "green" => array(
        "numbers" => array(1 => "#ffffff"
    ),
    "yellow" => array(
        "numbers" => array(6 => "#81c77d"
    ),
    "white" => array(
        "numbers" => array(24 => "#81e87c"
    ),
    "grey" => array(
        "numbers" => array(0 => "#ffffff"
    ),
    "red" => array(
        "numbers" => array(34 => "#dfb07b"
    )
);

Upvotes: 0

Views: 54

Answers (3)

n-dru
n-dru

Reputation: 9430

You are missing parentheses - they are always needed to pair up. It should look like this:

$property = array(
    "green" => array(
        "numbers" => array(1 => "#ffffff")
    ),
    "yellow" => array(
        "numbers" => array(6 => "#81c77d")
    ),
    "white" => array(
        "numbers" => array(24 => "#81e87c")
    ),
    "grey" => array(
        "numbers" => array(0 => "#ffffff")
    ),
    "red" => array(
        "numbers" => array(34 => "#dfb07b")
    )
);

Use an IDE like Eclipse or Aptana Studio which will show you the syntax errors while you type so that you won't need to run the code to see something is wrong.

Upvotes: 1

Drudge Rajen
Drudge Rajen

Reputation: 7987

$property = array(
    "green" => array(
        "numbers" => array(1 => "#ffffff")
    ),
    "yellow" => array(
        "numbers" => array(6 => "#81c77d")
    ),
    "white" => array(
        "numbers" => array(24 => "#81e87c")
    ),
    "grey" => array(
        "numbers" => array(0 => "#ffffff")
    ),
    "red" => array(
        "numbers" => array(34 => "#dfb07b")
    ),
);

You missed parenthesis.

Upvotes: 1

Grv
Grv

Reputation: 373

$property = array(
    "green" => array(
        "numbers" => array(1 => "#ffffff")
    ),
"yellow" => array(
    "numbers" => array(6 => "#81c77d")
),
"white" => array(
    "numbers" => array(24 => "#81e87c")
),
"grey" => array(
    "numbers" => array(0 => "#ffffff")
),
"red" => array(
    "numbers" => array(34 => "#dfb07b")
)
);

Parenthesis after the hex code

Upvotes: 1

Related Questions