Answer the question
In order to leave comments, you need to log in
How to sum values with same names?
By referring to MySQL with a specific query, I get an array with the values of different tables. Can I change my query so that instead of two repeating array elements with the name "Food and Drinks" I get one element, where the amount of elements with the repeating name will be summed up? It turns out I want the array to have an element with the name "Food and Drinks", where amount = "700".
Answer the question
In order to leave comments, you need to log in
You can also call array_combine([id,name], array_map(null, $result)) and instead get
[
0 => [ id => 1, name => 'vasya' ],
1 => [ id => 2, name => 'petya' ],
]
[
id => [ 1,2 ],
name => [ vasya, petya ],
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question