0

次のような PDO Fetch_assoc からの var_dumped Array があります。

array
  0 => 
    array
      'Client_Firstname' => string 'Sandrah' (length=...)
      'Client_Lastname' => string 'Lewis' (length=...)
      'Client_Email' => string 'san@lewis.com' (length=...)
      'Purchased_ItemId' => int '16' (length=...)
      'ItemName' => string 'MiniPad' (length=...)
      'ItemPrice' => string '500.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)
  1 => 
     array
      'Client_Firstname' => string 'Derick' (length=...)
      'Client_Lastname' => string 'Smith' (length=...)
      'Client_Email' => string 'der@smith.com' (length=...)
      'Purchased_ItemId' => int '10' (length=...)
      'ItemName' => string 'MegaPad' (length=...)
      'ItemPrice' => string '1500.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)
  2 => 
     array
      'Client_Firstname' => string 'Sandrah' (length=...)
      'Client_Lastname' => string 'Lewis' (length=...)
      'Client_Email' => string 'san@lewis.com' (length=...)
      'Purchased_ItemId' => int '18' (length=...)
      'ItemName' => string 'Xpower Speakers' (length=...)
      'ItemPrice' => string '300.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)
  3 => 
     array
      'Client_Firstname' => string 'Sandrah' (length=1)
      'Client_Lastname' => string 'Lewis' (length=7)
      'Client_Email' => string 'san@lewis.com' (length=7)
      'Purchased_ItemId' => int '7' (length=7)
      'ItemName' => string 'Lion Belt' (length=7)
      'ItemPrice' => string '800.00' (length=7)
      'ItemType' => string 'Fashion' (length=7)
      'date' => string '2013-12-12' (length=7)
  4 => 
    array
      'Client_Firstname' => string 'Sandrah' (length=1)
      'Client_Lastname' => string 'Lewis' (length=7)
      'Client_Email' => string 'san@lewis.com' (length=7)
      'Purchased_ItemId' => int '27' (length=7)
      'ItemName' => string 'FT Card Reader' (length=7)
      'ItemPrice' => string '20.00' (length=7)
      'ItemType' => string 'Hardware' (length=7)
      'date' => string '2013-12-12' (length=7)
  5 => 
     array
      'Client_Firstname' => string 'Jonathan' (length=1)
      'Client_Lastname' => string 'Homad' (length=7)
      'Client_Email' => string 'jon@homad.com' (length=7)
      'Purchased_ItemId' => int '20' (length=7)
      'ItemName' => string 'MiniPad' (length=7)
      'ItemPrice' => string '500.00' (length=7)
      'ItemType' => string 'Hardware' (length=7)
      'date' => string '2013-12-12' (length=7)

目的は、出力で、各クライアントの名、姓、および電子メールが 1 回だけ表示され、その後にすべてのトランザクションが続くようにすることです。

何かのようなもの:

array
  0 => 
    array
      'Client_Firstname' => string 'Sandrah' (length=...)
      'Client_Lastname' => string 'Lewis' (length=...)
      'Client_Email' => string 'san@lewis.com' (length=...)
      'Purchased_ItemId' => int '16' (length=...)
      'ItemName' => string 'MiniPad' (length=...)
      'ItemPrice' => string '500.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)
      'Purchased_ItemId' => int '18' (length=...)
      'ItemName' => string 'Xpower Speakers' (length=...)
      'ItemPrice' => string '300.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)
      'Purchased_ItemId' => int '7' (length=...)
      'ItemName' => string 'Lion Belt' (length=...)
      'ItemPrice' => string '800.00' (length=...)
      'ItemType' => string 'Fashion' (length=...)
      'date' => string '2013-12-12' (length=...)
      'Purchased_ItemId' => int '27' (length=...)
      'ItemName' => string 'FT Card Reader' (length=...)
      'ItemPrice' => string '20.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)

  1 => 

     array
      'Client_Firstname' => string 'Derick' (length=...)
      'Client_Lastname' => string 'Smith' (length=...)
      'Client_Email' => string 'der@smith.com' (length=...)
      'Purchased_ItemId' => int '10' (length=...)
      'ItemName' => string 'MegaPad' (length=...)
      'ItemPrice' => string '1500.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)

  2 => 

     array
      'Client_Firstname' => string 'Jonathan' (length=...)
      'Client_Lastname' => string 'Homad' (length=...)
      'Client_Email' => string 'jon@homad.com' (length=...)
      'Purchased_ItemId' => int '20' (length=...)
      'ItemName' => string 'MiniPad' (length=...)
      'ItemPrice' => string '500.00' (length=...)
      'ItemType' => string 'Hardware' (length=...)
      'date' => string '2013-12-12' (length=...)

私によると、各配列の唯一の一意の識別子は電子メール アドレスです。そのため、他のSO関連の質問に導かれて、forループ、foreachループを使用して電子メールアドレスに従ってそれらをグループ化しようとしましたが、これはまだ達成されていません。

どんな助けでも大歓迎です。

4

0 に答える 0