Seems like a convoluted way to do whatever this is, but yeah, here's a simple way to generate that - all untested and may contain stupid bugs because I've got a headache, but here you go...
First build the array of weeks:
$marking = [ strtotime('sunday') * 1000 ];
for ( var $i = 1 ; $i <= 52 ; $i++ )
$marking[i] = strtotime((-1*$i).' week sunday') * 1000;
Then re-map each one into the desired format (use a better function name):
function convert_to_my_format( $CurMarking )
{
return "{ xaxis: { from: ".($CurMarking+10000000).", to: ".($CurMarking-96400000)." }, color: \"#F3F3ED\" }";
}
$markings = array_map( "convert_to_my_format" , $marking );
Finally convert that array into a comma-delimited string:
$markings = implode( "," , $markings );
|