I need an array to be created with a PHP loop.
It will look like:
[ utcdate1:[ series1:[value], series2:[value], series3:[value], utcdate2:[ series1:[value], series2:[value], series3:[value], etc..... ]
Here is my code:
totals = { <?php
for ($i=0; $i < count($date); $i++) {
echo "Date.UTC(".
$year[$i].",".
$month[$i].",".
$day[$i].
"):[ Movies:[".$nomovies[$i].
"], Shows:[".$noshows[$i].
"], Music:[".$nomusic[$i].
"] ]";
if ($i < (count($date)-1)) {
echo ",";
}
} ?> };
Why doesn’t this code work?
You cannot compute JS property name on the fly. Try this:
EDIT:
While we’re at it, JavaScript is not Java. JavaScript runs in browsers and is the future of HTML5. Java commonly runs on server, as programs, or as applet, and is now a static type traditional programming language. They are quite different, really, both in syntax and in concept.
So, tag wisly next time.