Hello. Please tell me why an error is issued.

syntax error, unexpected '['

static $points = [ '1' => ['3' => 8.4, '2' => 7.1, '4' => 5.3], '2' => ['5' => 9.1], '3' => ['6' => 8.2, '5' => 4.2], '4' => ['6' => 7.3], '5' => ['6' => 6.3], ]; 

The language in which it is written php

  • I do not have such an error. Perhaps you should remove the comma in the line: > '5' => ['6' => 6.3], - Genome
  • 3
    You have a php version lower than php 5.4. In which you can declare an array in this way. Go to the version above, or use array() - Alexey Shimansky

1 answer 1

As АлСксСй Шиманский has already stressed, you have a problem with the PHP version, it is lower than version 5.4.

In versions >= 5.4 added the ability to declare an array using [] .

To solve the problem, you need to replace all [...] with array(...) .

As a result, your code will look like this:

 static $points = array( '1' => array('3' => 8.4, '2' => 7.1, '4' => 5.3), '2' => array('5' => 9.1), '3' => array('6' => 8.2, '5' => 4.2), '4' => array('6' => 7.3), '5' => array('6' => 6.3), ); 

Documentation link