开发者

Syntax error with PHP array definition

Can anyone tell me what is wrong with this code block?

The PHP compiler says:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /Users/mrunkel/Dropbox/Documents/New Store/Data Migration/utils/test.php on line 3 (sorry, I couldn't format this correctly, line 3 is the line that starts with "0050")

$data = array (
          "0010" => array ("1 to 10", 1, 10),

          "0050" => array("11 to 50", 11, 50),

          "0150" => array("51 to 150", 51, 150),

          "0500" => array("151 to 500", 151, 500),

          "1500" => array("501 to 1500", 501, 1500),

          "3000" => array("1501+", 1501, "")
);

This looks like an example straight out of php manual page for multi-dimensional arrays. I've tried adjusting the keys to integers, I've tried adjusting the values to integers or all strings, I keep getting the sa开发者_如何转开发me error.

I'm sure it's something stupid, but I just don't see it.

Thanks,

Marc


I don't know why but after each comma you have a unicode character u+8232 which is invisible here but I can see them after I copy/pasted your code into my editor. remove those and you'll be fine.


Use this

$data = array(0010 => array ("1 to 10", 1, 10),
'0050' => array("11 to 50", 11, 50),
    
'0150' => array("51 to 150", 51, 150),
'0500' => array("151 to 500", 151, 500),
1500 => array("501 to 1500", 501, 1500),
3000 => array("1501+", 1501, "")); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜