I have a multidimensional array of elements that are grouped by months, for example:
Array
(
[2013-01] => Array
(
[0] => Array
(
[Project] => Array
(
[id] => 1
[user_id] => 1
[created] => 2013-04-08 01:00:56
[modified] => 2013-04-08 01:01:40
[vId] => 7
)
)
)
[2013-04] => Array
(
[2] => Array
(
[Project] => Array
(
[id] => 1
[user_id] => 1
[created] => 2013-04-08 01:00:56
[modified] => 2013-04-08 01:01:40
[refimg] => uploads/smallRef.png
)
)
[3] => Array
(
[Project] => Array
(
[id] => 1
[user_id] => 1
[created] => 2013-04-08 01:00:56
[modified] => 2013-04-08 01:01:40
)
)
[4] => Array
(
[Project] => Array
(
[id] => 1
[user_id] => 1
[created] => 2013-04-08 01:00:56
[modified] => 2013-04-08 01:01:40
)
)
)
)
Now I want to loop through months, and for each month I want to perform a count on the array for the specific month:
$currMonth = date('Y-m-d');
while (strtotime($currMonth) >= strtotime($firstMonth)) {
$curM = date('Y-m', strtotime($currMonth));
count($grouparr[$curM]);
$currMonth = date ("Y-m-d", strtotime("-1 month", strtotime($currMonth)));
}
This does not seem to work. I get the following error:
Uncaught SyntaxError: Unexpected token <
If I enter the date manually everything works fine, for example if I replace this in the code above:
count($grouparr["2013-01");
I hope someone can tell me what I am doing wrong
<
character in the code – Ed Heal Apr 11 at 16:53<
in the code you posted... – mattedgod Apr 11 at 16:53