im trying to reverse the results in my foreach loop, I am aware that I could try using array_reverse however that does not reverse the output of the loop.
the results currently look like this
[new Date(2012, 05, 16), 630.10, 615.94],
[new Date(2012, 05, 15), 615.00, 603.75],
[new Date(2012, 05, 14), 608.50, 600.58],
[new Date(2012, 05, 11), 614.55, 604.77],
[new Date(2012, 05, 10), 616.19, 610.23],
the output I want is
[new Date(2012, 05, 10), 616.19, 610.23],
[new Date(2012, 05, 11), 614.55, 604.77],
[new Date(2012, 05, 14), 608.50, 600.58],
[new Date(2012, 05, 15), 615.00, 603.75],
[new Date(2012, 05, 16), 630.10, 615.94],
this is my code.
foreach($stockcontentex as $stockexplode){
$stockex = explode(',',$stockcontentex[$i++]);
$stockexdate = explode('-', $stockex[0]);
$stockYear = $stockexdate[0];
$stockMonth = $stockexdate[1];
$stockDay = $stockexdate[2];
$stockHigh = $stockex[2];
$stockLow = $stockex[3];
$_str .= '[new Date('.$stockYear.', '.$stockMonth.', '.$stockDay.'), '.$stockHigh.', '.$stockLow.'],'. "\n";
}
any help is appreciated, im not sure if there is any additional info that may be needed.
thanks
Use
array_reverseand then swap this:with this:
Alternately, you could switch
.=for: