0

I'm fairly new to PHP, and I'm looking to do a fairly simple operation related to array manipulation. This is the initial array i'm working with:

$Orders = array(    0 => array("Client" => "John Doe", "Product" => "Chairs",
                                "Ammount" => "14"),
                    1 => array("Client" => "John Doe", "Product" => "Chairs",
                                "Ammount" => "12"),
                    2 => array("Client" => "John Doe", "Product" => "Chairs",
                                "Ammount" => "18"));

This is the array I want to get by the end of the operation:

$Orders2 = array(0 => array("Client" => "John Doe", "Product" => "Chairs",
                                "Ammount" => array("14", "12", "18")
                                ));

As you can see the newly created array ($Orders2) is the result of a transformation of $Orders, it groups all the orders by client. I have a few ideas on how to do this, however it feels that each solution I come across is a bit to complex. Any ideas on how to provide a simple solution?

Renato Fonseca
  • 25
  • 1
  • 1
  • 7

0 Answers0