samedi 8 septembre 2018

how to sum array values with if condition

I have the following array. now I want to sum values which id is same. e.g. id=6 qty would be 25. help will be highly appreciated. Thanks

<pre>Array(
[0] => stdClass Object
    (
        [id] => 9
        [qty] => 5
    )
)
</pre><pre>Array
(
[0] => stdClass Object
    (
        [id] => 6
        [qty] => 10
    )

[1] => stdClass Object
    (
        [id] => 7
        [qty] => 5
    )
) 
</pre><pre>Array
(
[0] => stdClass Object
    (
        [id] => 6
        [qty] => 15
    )
)
</pre>

Aucun commentaire:

Enregistrer un commentaire