Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an array I want to contain objects but it keeps returning
JavaScript
Parse error: syntax error, unexpected 'Object' (T_STRING), expecting ')' 

A closer look at what causes such errors reveals it occurs when strings are not wrapped in quotes but I can't seem to decipher what string I'm not wrapping. My code is posted below
PHP
$all_users = Array
(
    [user_name] => Admin Object
        (
            [can_comment] => 1
            [can_view_announcements] => 1
            [profile_pic] => "/dir/accounts/assets.png"
            [can_delete_comment] => 1
        )
)


What I have tried:

The code that creates this is
$all_users = array();
$user_name = new Member("user_name");
$all_users['user_name'] = $user_name;

Please what is wrong with it?
Posted
Updated 21-Mar-16 12:25pm
v2
Comments
Sinisa Hajnal 22-Mar-16 3:27am    
Try separating the call to several distinct lines and/or commenting out one by one until you find which one causes trouble. My guess would be that Admin Object needs quotes or underscore between the words or parentheses of some kind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900