Why does this work:
$optionArray = get_option('myplugin_options');
$optionArray = $optionArray['defaultButton'];
But not this?
$optionArray = get_option('myplugin_options')['defaultButton'];
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t access an array using that syntax when it’s returned directly from a function like that, you’ll get a syntax error in PHP. Other languages might let you do this sort of thing (I think Python does), but it’s not correct in PHP (at least up to the current 5.3.x versions).
Wrapping the function in parentheses or curly braces doesn’t help either, you’ll still get a syntax error:
gives the following error:
Maybe in future versions of PHP it might be possible to access arrays like this, but for now, you’re just going to have to assign them to variables first: