I have a small question for you all. I currently have my site on 000webhost, and the following line:
$price = explode(".",$item->sellingStatus->currentPrice)[0];
causes the following error:
Parse error: syntax error, unexpected '[' in /home/a1257018/public_html/scripts/myfile.php on line 58
When it doesn't cause this on localhost. The code should work... explode returns an array and [0]
simply calls the first item. Why is this throwing an error?
This syntax is only allowed in PHP 5.4+. You have to use temporary variables in older versions:
$tmp = explode('.', $item->sellingStatus->currentPrice);
$price = $tmp[0];
Has been discussed on SO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With