I'm really struggling to get my head around multi-dimensional arrays in PHP, my background is C and Java both of which I have no issues with arrays!
I'm trying to read from an SQL database a list of months, each month has a list of values corresponding to a value.
ie.
2014-01-01, ("Val1", "Val2", "Val3", "Val4", "Val5"), (3, 4, 7, 5, 3)
2014-02-01, ("Val1", "Val2", "Val3", "Val4", "Val5"), (5, 3, 6, 2, 8)
2014-03-01, ("Val1", "Val2", "Val3", "Val4", "Val5"), (6, 5, 4, 3, 2) ...
I can read the values, I can split them down, but I want to be able to add those values to an array but putting the values into the correct month.
I c/Java I'd just create an array like this;
[0,0,0,0,0,0,0,0,0,0,0,0] - Val1 goes in here
[0,0,0,0,0,0,0,0,0,0,0,0] - Val2 goes in here
[0,0,0,0,0,0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0,0,0,0] - Val5 goes in here
then as I parse through the values, I'd pick up the month, and add the values I read into the correct month.
I can create the array in PHP, all I need to know, is there a blindingly obvious way that I've missed in my coffee/sleep deprived state that I can basically say something like;
If I want to change position 11 in the the 2nd array to 6 in C I would be this;
array[2][11] = 6
is there an equivalent to do this in PHP?
$array[2][11] = 6;not working for you?$arr[2][11] = 6, assuming your array is numerically indexed. Please show your complete code so we can get a better understanding$array[1][11]for the second array?