Monday, April 10, 2017

PHP sum if equal in array

I am using Laravel to get data from my database using this eloquent

$results = Client::whereIn('po', $pos) -> get();

And here is my blade code

@foreach($results as $result)
        <tr>
            <td></td>
            <td></td>
        </tr>
@endforeach

What I am trying to do

The result will return two duplicated columns under each other.

So I want to sum the two columns value of duplicated and print it in only one row with both columns sum.

Kindly check the image it will show everything in a simple fast way Click to see image



via Frank

Advertisement