0

I get an error on this line:

$name = $html->find('a.ProfileHeaderCard-nameLink')[0]->plaintext;

The error is:

Parse error: syntax error, unexpected '[' 

How can I make this work? It works perfectly on localhost for some reason.

Ilya Spark
  • 157
  • 1
  • 2
  • 9

2 Answers2

2

Try this ,

$name = $html->find('a.ProfileHeaderCard-nameLink');
$name = $name[0]->plaintext;
Moby M
  • 910
  • 2
  • 7
  • 26
0

Are you sure you are running the same PHP versions locally and on your server? Accessing an array directly after returning it from a functin is a feature added in PHP 5.4, see http://php.net/manual/en/migration54.new-features.php

Nico Haase
  • 11,420
  • 35
  • 43
  • 69