• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Ranges in 3D Arrays

#1
[eluser]Louis C.[/eluser]
Here's my three-dimensional array:

Code:
private $all_goals = array(
    'steps_10k' => array(
      0 => range(0, 1999),    # This is line 7
      1 => range(2000, 2999),
      2 => range(3000, 3999),
      3 => range(4000, 4999),
      4 => range(5000, 5999),
      5 => range(6000, 6999),
      6 => range(7000, 7999),
      7 => range(8000, 8999),
      8 => range(9000, 9999),
      9 => range(10000, 25000)
    ),
    'steps_8k' => array(
      0 => range(0, 1599),
      1 => range(1600, 2399),
      2 => range(2400, 3199),
      3 => range(3200, 3999),
      4 => range(4000, 4799),
      5 => range(4800, 5599),
      6 => range(5600, 6399),
      7 => range(6400, 7199),
      8 => range(7200, 8999),
      9 => range(9000, 25000)
    )
  );

That code is located inside of a model. When I try to load the URL for the controller function that uses that model, I get this error:

2011/04/05 20:07:14 [error] 28546#0: *1047 FastCGI sent in stderr: "PHP Parse error: syntax error, unexpected '(' in /home/louis/web/application/models/researcher.php on line 7" while reading response header from upstream, ...

Line 7 of the file is noted above. When I replace the range expression with a string, line 8 produces the same error. I think there's a syntax problem here, but I can't see it. Or can ranges, which, according to the PHP manual, are arrays, not be used as values in arrays?

#2
[eluser]wh1tel1te[/eluser]
That array works for me. You must have an error somewhere else in your code. I suspect it might be an unclosed bracket.

#3
[eluser]Louis C.[/eluser]
Thanks for checking. Sometimes I stare at the same code block for so long looking for a solution that I forget the problem may lie elsewhere.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.