I've noticed several examples of code like this:

if (!$may_cache){
45 $items[] = array (
46 'path' => 'node/add/demo',
47 'title' => t('demo'),
48 'access' => user_access('create demo'),
49 );
50 $items[] = array (
51 'path' => 'demo/example',
52 'callback' => '_demo_show',
53 'access' => user_access('view example'),
54 'type' => MENU_CALLBACK,
55 );
...

It seems to me that $items is being instantiated and then immediately overwritten with new values. What is going on here? Is $items[] an array of two arrays?

Comments

heine’s picture

See http://www.php.net/manual/en/language.types.array.php :

Note: As mentioned above, if you provide the brackets with no key specified, then the maximum of the existing integer indices is taken, and the new key will be that maximum value + 1 . If no integer indices exist yet, the key will be 0 (zero). If you specify a key that already has a value assigned to it, that value will be overwritten.

--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.