Get a variable from object in array [closed]

Probably your hosting server has a different and older version of php so this syntax is not supported.

The above syntax is implemented in PHP 5.4.

You have to do it like this:

$category = get_the_category($id);
echo $category[0]->slug;

Source:

https://bugs.php.net/bug.php?id=45906