1

Am I right that the following syntax works in PHP 5.4 but doesn't work in PHP 5.3?

$users[$key]['class'] = $class->row_array()['name'];

The row_array() function is a CodeIgniter function which returns an array. I was stumbled when I found out that none of my code worked when I moved it to the live server, this is very frustrating of course because now I'll have to refactor everything.

Can anyone please tell me if this is related to the PHP version and if there is a possible easier solution rather than refactoring everything?

2
  • Changing host seems easier ;) Commented May 26, 2013 at 1:40
  • School server unfortunately. ;) Commented May 26, 2013 at 2:17

1 Answer 1

4

Array dereferencing has been introduced in PHP5.4

As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.

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

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

Comments

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.