views:

149

answers:

5

Here is my code:

$today = date('Y-m-d');

for ($i = 1; $i <= 10; $i ++){
$var_b[$i]  = date('Y-m-d', strtotime('-' . $i .' day', strtotime($today)));
$var2_b[$i]_name = date('d', strtotime($var_b[$i]));

Error message:

Parse error: syntax error, unexpected T_STRING in XXX\index.php on line XX

EDIT:

I put the curly brackets, the error message line on this one:

$var2_b[$i] = date('d', strtotime($var_b[$i]));
+3  A: 

Where is your closing }? (Also remember that array indexing starts with 0)

Dario
+3  A: 

You need the closing curly brace } for your for loop.

$today = date('Y-m-d');
for ($i = 1; $i <= 10; $i++) {
  $var_b[$i]  = date('Y-m-d', strtotime('-' . $i .' day', strtotime($today)));
  $var2_b[$i] = date('d', strtotime($var_b[$i]));
}
Travis Beale
+1  A: 

You are missing the closing curly bracket.

}

Richard Testani
A: 

Please close your for loop's curly brace...

Also was the error on one of the lines in the code provided?

His code runs fine in a test script - gotta be the curly brace.
Josh
yeah, i have edit and include the line of errors, i also confuse, since everone said my code is correct, then what does the error message keep appear??
jingleboy99
Your code is NOT correct. You are missing a closing curly brace at the end of the loop... for() { ...code here... }
A: 

I tested your code, adding the closing brace, and it doesn't report an error. Are you sure the line you changed to XX is in the code you supplied?

Petruza