1

I have following array

Array
(
     [0] => Array(
         [0] => Water
         [1] => 0.5555)
     [1] => Array(
         [0] => Jojoba Oil
         [1] => 1)
     [2] => Array(
         [0] => Water
         [1] => 0.3)
     [3] => Array(
         [0] => Coconut Extract
         [1] => 1.2)
     [4] => Array(
         [0] => Walnut Extract
         [1] => 1.1)
     [5] => Array(
         [0] => Water
         [1] => 0.5555)
     [6] => Array(
         [0] => Peptide 1
         [1] => 2)
     [7] => Array(
         [0] => Preservative
         [1] => 0.5555)
)

And I need the following output(by adding the value of repetitive key and display once e.g 'Water')

Array(
[Peptide 1] => 2 
[Water] => 1.411 
[Coconut Extract] => 1.2 
[Walnut Extract] => 1.1 
[Jojoba Oil] => 1 
[Preservative] => 0.5555
)

var dump output:- var dump output

and also sort by the sum in desc order Thanx in advance...

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.