$marking0 = strtotime('sunday') * 1000; $marking0a = $marking0 - 96400000; $marking0 = $marking0 + 10000000; $marking1 = strtotime('-1 week sunday') * 1000; $marking1a = $marking1 - 96400000; $marking1 = $marking1 + 10000000; $markings = " { xaxis: { from: $marking0, to: $marking0a }, color: \"#F3F3ED\" }, { xaxis: { from: $marking1, to: $marking1a }, color: \"#F3F3ED\" } " ;I need the same thing 52 times eg
$marking2 = strtotime('-2 week sunday') * 1000; $marking2a = $marking2 - 96400000; $marking2 = $marking2 + 10000000; $marking3 = strtotime('-3 week sunday') * 1000; $marking3a = $marking3 - 96400000; $marking3 = $marking3 + 10000000; ...... $marking52 = strtotime('-52 week sunday') * 1000; $marking52a = $marking52 - 96400000; $marking52 = $marking52 + 10000000; $markings = " { xaxis: { from: $marking0, to: $marking0a }, color: \"#F3F3ED\" }, { xaxis: { from: $marking1, to: $marking1a }, color: \"#F3F3ED\" }, { xaxis: { from: $marking2, to: $marking2a }, color: \"#F3F3ED\" }, { xaxis: { from: $marking3, to: $marking3a }, color: \"#F3F3ED\" }, ....... { xaxis: { from: $marking52, to: $marking52a }, color: \"#F3F3ED\" } " ;There must be a pretty simple way to generate 52 of those without doing it all manually?
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 );
for ( $i = 1 ; $i <= 52 ; $i++ ) $marking[i] = strtotime((-1*$i).' week sunday') * 1000; function convert_to_markings( $CurMarking ) { return "{ xaxis: { from: ".($CurMarking).", to: ".($CurMarking-96400000)." }, color: \"#F3F3ED\" }"; } $markings = array_map( "convert_to_markings" , $marking ); $markings = implode( "," , $markings );Output from that is
{ xaxis: { from: 1425168000000, to: 1425071600000 }, color: "#F3F3ED" }
...of an idiot who doesn't know what things are. :S
Hmm, bit harsh? Maybe just a dunce. (hug)
jQuery neither prefixes variable names not puts dollars in front of selectors. It aliases itself as $, and as a function it can have arguments, the first of which can be a selector, though it also can be other things, and also has various methods attached to the function's object itself.
Which is not to say it isn't a bit dumb, but it is at least more convenient than typing case sensitive jQuery, though even that isn't as $durbrained $as $bloody $_PHP.