Advertisement
yudhaez0212

Untitled

Nov 30th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. $data = [
  4. [
  5. 'id' => 1,
  6. 'users_id' => 100,
  7. 'account' => 9000000
  8. ],
  9. [
  10. 'id' => 2,
  11. 'users_id' => 100,
  12. 'account' => 4000000
  13. ],
  14. [
  15. 'id' => 3,
  16. 'users_id' => 100,
  17. 'account' => 5000000
  18. ],
  19. [
  20. 'id' => 4,
  21. 'users_id' => 200,
  22. 'account' => 1000000
  23. ],
  24. [
  25. 'id' => 5,
  26. 'users_id' => 300,
  27. 'account' => 2000000
  28. ],
  29. ];
  30. foreach ($data as $d) {
  31. $tmp_data[$d['users_id']][] = $d;
  32. }
  33.  
  34. $result = $tmp_data;
  35.  
  36. foreach ($data as $d) {
  37. // cara mengakses yang sudah di indexing by users_id
  38. var_dump($result[$d['users_id']]);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement