0

I have this code:

menu.php

<?php $menu = [ [ "id"->"home", "name"->"Home page", "url"->"/index.php" ] }; ?> 

index.php

<?php require 'menu.php'; $menubar = [ "menu" -> $menu, "current" -> "home" // this line ]; ?> <!-- and some html --> 

And, of course, it isn't working.

Parse error:

syntax error, unexpected '"home"' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in D:\xampp\htdocs\index.php on line 11`

How to repair this?

1 Answer 1

2

just use "aaa"=>"bbb" instead of "aaa"->"bbb" with =

see http://php.net/manual/en/language.types.array.php

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

1 Comment

Wow, I didn't think it is that simple ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.