CodeIgniter Forums
Problem with Ranges in 3D Arrays - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problem with Ranges in 3D Arrays (/showthread.php?tid=40340)



Problem with Ranges in 3D Arrays - El Forum - 04-05-2011

[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?


Problem with Ranges in 3D Arrays - El Forum - 04-05-2011

[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.


Problem with Ranges in 3D Arrays - El Forum - 04-05-2011

[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.