3
array(10) {
[0]=>
array(4) {
["data"]=>
string(10) "01/11/2015"
["valor"]=>
int(50)
["intensidade"]=>
float(37.5)
["carga"]=>
int(35)
}
[1]=>
array(4) {
["data"]=>
string(10) "01/11/2015"
["valor"]=>
int(52)
["intensidade"]=>
float(33.8)
["carga"]=>
int(60)
}
[2]=>
array(4) {
["data"]=>
string(10) "01/11/2015"
["valor"]=>
int(25)
["intensidade"]=>
float(21.75)
["carga"]=>
int(15)
}
[3]=>
array(4) {
["data"]=>
string(10) "02/11/2015"
["valor"]=>
int(52)
["intensidade"]=>
float(33.8)
["carga"]=>
int(60)
}
[4]=>
array(4) {
["data"]=>
string(10) "02/11/2015"
["valor"]=>
int(52)
["intensidade"]=>
float(33.8)
["carga"]=>
int(60)
}
[5]=>
array(4) {
["data"]=>
string(10) "05/11/2015"
["valor"]=>
int(52)
["intensidade"]=>
float(33.8)
["carga"]=>
int(60)
}
}
So, I have this array and I need to calculate the data of the same date and divide by as many times as it appears, after that I need to generate again the array with the new data.
And what you tried to do so far?
– gmsantos
Well, all this was in one array, I used the foreach to break and identify each array, then tried to do some things and nothing worked.
– Bruno Kaue
I know I need to do at the end an array containing 3 arrays inside each with its date.
– Bruno Kaue
Try to explain the context of your problem better. Your array comes from somewhere, where? The way you expose your doubt can help you a lot to get good answers. You can [Dit] your question to make it clear but after reading [Ask] and the [tour].
– gmsantos
The question is very explanatory, I have an array, this array comes from the database, I’m pulling these values, but sometimes there is equal data in matter of date, I just need to add them because these values are placed in a graph, and is appearing several times the same day.
– Bruno Kaue
Her last comment gives a very important context to your question that is not in her body: the data comes from the database. You can directly average per date in your query by eliminating the extra step of having to deal with it in the application. If your array came from a webservice where you can’t do that, that would be another approach. You know what I mean about the lack of context in the question?
– gmsantos
No, it cannot be done, because all the data coming from there is already filtered and done the math.
– Bruno Kaue