0

enter image description here

This is my first array which i get from mysql

Array    
([0] => Array
    (
        [created_by] => 4
        [count] => 1
        [total] => 300
    )

[1] => Array 
    (
        [created_by] => 4
        [count] => 1
        [total] => 450
    )

[2] => Array
    (
        [created_by] => 3
        [count] => 1
        [total] => 500
    )

)

I need a output as

[0] => Array
    (
        [created_by] => 4
        [count] => 2
        [total] => 750
    )

[1] => Array
    (
        [created_by] => 3
        [count] => 1
        [total] => 500
    )

Sum of array total based on created_by Need to group by created_by count.

Jegadeesh
  • 1
  • 3
  • 2
    Also show the PHP code where the source array is build if MySQL is involved also show the table structure with example data.. A MySQL query is much easier to get the array structure you need something like `SELECT created_by, COUNT(*) AS count, SUM(total) AS total FROM table GROUP BY created_by`.. For now i vote close this question to be unclear read this https://stackoverflow.com/help/how-to-ask.. – Raymond Nijland Apr 28 '18 at 20:44
  • i have joined from two tables..not possible in mysql.any idea in php – Jegadeesh Apr 28 '18 at 20:47
  • 1
    "i have joined from two tables..not possible in mysql" `COUNT(*)`, `SUM()` and `GROUP BY` also work on JOINED tables iám sure it's possible in pure MySQL only. So show the code and table structures with example data on sqlfiddle.com.. – Raymond Nijland Apr 28 '18 at 20:48

0 Answers0