Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I started receiving a strange PHP error, the script was working fine on the server, but when I set up locally I get a PHP parse error but everything is looking good. The error is on this line:

$MaxBet = array_values($maxbet)[$Cnt];

From this snippet

$Cnt = 0;
foreach ($pcent as $val) {
    $MaxBet = array_values($maxbet)[$Cnt];
    $Payout = array_values($payout)[$Cnt];
    echo "<a href='#' id={$Cnt}>Less than {$val} Max bet:{$MaxBet} Payout:x{$Payout}</a><br>";
    $Cnt++;
}

Both web server and local setup using nginx and php5-fpm.

share|improve this question
2  
Array dereferencing is supported from PHP 5.4 onwards. –  mario Feb 1 at 15:37
    
yep server php version 5.4 local 5.3!! –  James Kirkby Feb 1 at 15:45
    
yep upgrade your local server –  Hamza Feb 1 at 17:03

1 Answer 1

As @mario said in the comments, you can only using array dereferencing in PHP 5.4+. Array dereferencing refers to accessing an array index directly from a function call, e.g:

$MaxBet = array_values($maxbet)[$Cnt];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.