0

I have the following code:

public function postFormAction(Request $request)
{

    $cityId = $request->request->get('shopiousUserBundle_user')['location']['city']; 
    .....
}

for some reason this is giving me a syntax error, any idea why? When I remove the array indexing to be just like:

$cityId = $request->request->get('shopiousUserBundle_user')

works fine.

1
  • When posting a question that involves any kind of error message, you should always add the specific error message to the question Commented Apr 9, 2013 at 1:12

1 Answer 1

4

Array dereferencing from the result of a function call is only available in PHP 5.4 or later.

See http://php.net/manual/en/language.types.array.php#example-88

If you are using an earlier PHP version, you will have to do the following

$data = $request->request->get('shopiousUserBundle_user');
$cityId = $data['location']['city'];
Sign up to request clarification or add additional context in comments.

1 Comment

ah.. I thought it was available in 5.3 and above.. thanks a bunch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.