arraysphp-7php-5.6

How to make this array assignment work in php5.6?


I have a part of code, that was written in php7:

[$columns, $values, $conditions] = $this->gatherConditions($identifier);

where $identifier is an array. When I run this code on php5.6 server it shows error - unexpected "=" on line X. How this line should be written for working in php 5.6?


Solution

  • The equivalent in PHP before the short-array syntax list-destructuring was allowed in PHP 7.1, is

    list($columns, $values, $conditions) = $this->gatherConditions($identifier);

    See the php.net/list page: https://www.php.net/manual/en/function.list.php