I have got a 2d array called $myarray, and when I using var_dump($myarray), it gives me the following:
array(4) { [0]=> array(2) { [0]=> string(3) "EUR" [1]=> string(9) "43,543.23" } [1]=> array(2) { [0]=> string(3) "USD" [1]=> string(9) "13,432.34" } [2]=> array(2) { [0]=> string(3) "GBP" [1]=> string(8) "3,432.21" } [3]=> array(2) { [0]=> string(3) "CAD" [1]=> string(8) "2,321.34" } }
But I want the output to be the follwing format:
Totals
GBP 3,432.21
USD 13,432.34
EUR 43,543.23
CAD 2,321.34
I assume that I need to sort the array to be:
GBP 3,432.21
USD 13,432.34
EUR 43,543.23
CAD 2,321.34
and add “Totals”, “” into the array, I might be wrong, soanybody could help me with that, any help will be greatly appreciated! I want it to be done in a programmatic way! how to sort the array $myarray to the expected output?
Firstly, do not add anything non-data related to your array. You the string “Totals” should not be included in your array. If you just want the output, I suggest a better way to solve your problem :
I hope this helps.