Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = [
- [
- 'id' => 1,
- 'users_id' => 100,
- 'account' => 9000000
- ],
- [
- 'id' => 2,
- 'users_id' => 100,
- 'account' => 4000000
- ],
- [
- 'id' => 3,
- 'users_id' => 100,
- 'account' => 5000000
- ],
- [
- 'id' => 4,
- 'users_id' => 200,
- 'account' => 1000000
- ],
- [
- 'id' => 5,
- 'users_id' => 300,
- 'account' => 2000000
- ],
- ];
- foreach ($data as $d) {
- $tmp_data[$d['users_id']][] = $d;
- }
- $result = $tmp_data;
- foreach ($data as $d) {
- // cara mengakses yang sudah di indexing by users_id
- var_dump($result[$d['users_id']]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement