-3

I am facing the following error in PHP 5.3.29 environment

Parse error: syntax error, unexpected '[' in /home/deltaweb/www/schooler/templates/yoo_master2/schooler.php on line 1721

The code is snippet is

function getUserClassPermissions()
{
  $classStr = ['I','II','III','IV','V','VI','VII','VIII','IX','X'];
  $classes = array();
  $user = JFactory::getUser();
  $groups = implode(',',$user->getAuthorisedGroups());
  $results = getTableData("#__usergroups", "title", "id IN ($groups)");
  foreach ($results as $row) {
    if (preg_match("/Teacher Class (\S+)/",$row[0], $matches)) {
      $classes[] = array_search($matches[1], $classStr) + 1;
    }
  }
  if (count($classes)==0) return 0;
  return implode(',',$classes);
}

The statement in line number 1721 is

$classStr = ['I','II','III','IV','V','VI','VII','VIII','IX','X'];
Chandragupta Borkotoky
  • 1,596
  • 1
  • 11
  • 16

1 Answers1

4

Short array syntax, [] is only available in PHP5.4+. You need to update your code to use the standard array() syntax.

OR

Update your version of PHP to one that isn't EOL.

Jonnix
  • 4,121
  • 1
  • 30
  • 31
  • @chandra Just read the [documentation](http://php.net/manual/en/language.types.array.php) and you'll see loads of examples. – Jonnix May 18 '15 at 14:05