Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 same error.

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

Thanks,

Marc

share|improve this question
You might try closing the space between array and the open parentheses so it looks like array( instead of array (. – 65Fbef05 Aug 4 '11 at 22:42

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
Thanks so much. I have no idea how those got in there, but sure enough, that was the problem. – Marc Runkel Aug 4 '11 at 23:43

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, "")); 
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.