vendredi 18 septembre 2020

How To change Array stucture by user_id Laravel

I have array structure like this:

[
  {product:"A", user_id:1},
  {product:"B", user_id:2},
  {product:"C", user_id:1}
]

I want re-structure array by user_id like this:

[
  {user_id:1, product:["A","C"]},
  {user_id:2, product:["B"]}
]

How to change like that using php laravel, Thank you for your answer.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2H9gVzn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire