-4

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

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've copied the exact offending code block directly from my environment into the question.

3
  • You might try closing the space between array and the open parentheses so it looks like array( instead of array (. Commented Aug 4, 2011 at 22:42
  • I'm voting to close this as a typo question because, while reproducible if you directly copy the code from your question, this problem would go away if you carefully re-typed (from scratch) the code causing the problem which is the description of how one determines whether an issue is caused by a typo or not. Commented Jan 20 at 14:23
  • This is a good lesson in the dangers of copying code from somewhere else. I'm sure if you had typed it yourself from scratch you would not have run into this issue. Commented Jan 20 at 14:24

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.