3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = [ 0 =>[ 'nickname' => 'Bob', 'phone' => 15295892895, 'is_group' => 1, 'created_at' => 1544944181, 'assemble_id' => 'c1d0zUbmP', 'status' => 1 ], 1 =>[ 'nickname' => 'Jack', 'phone' => 15295892895, 'is_group' => 1, 'created_at' => 1544944181, 'assemble_id' => 'ED6OJX4VV', 'status' => 1 ], 2 =>[ 'nickname' => 'Grace', 'phone' => 15295892895, 'is_group' => 0, 'created_at' => 1544944181, 'assemble_id' => 'c1d0zUbmP', 'status' => 1 ], 3 =>[ 'nickname' => 'Jelly', 'phone' => 15295892895, 'is_group' => 0, 'created_at' => 1544944181, 'assemble_id' => 'ED6OJX4VV', 'status' => 1 ] ]; foreach ($list as $row) { $result[$row['assemble_id']]['assemble_id'] = $row['assemble_id']; $result[$row['assemble_id']]['assemble_group'][] = [ 'nickname' => $row['nickname'], 'phone' => $row['phone'], 'is_group' => $row['is_group'], 'created_at' => $row['created_at'], 'assemble_id' => $row['assemble_id'], 'status' => $row['status'] ]; } var_export(array_values($result));
Output for 5.6.38, 7.0.33, 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
array ( 0 => array ( 'assemble_id' => 'c1d0zUbmP', 'assemble_group' => array ( 0 => array ( 'nickname' => 'Bob', 'phone' => 15295892895, 'is_group' => 1, 'created_at' => 1544944181, 'assemble_id' => 'c1d0zUbmP', 'status' => 1, ), 1 => array ( 'nickname' => 'Grace', 'phone' => 15295892895, 'is_group' => 0, 'created_at' => 1544944181, 'assemble_id' => 'c1d0zUbmP', 'status' => 1, ), ), ), 1 => array ( 'assemble_id' => 'ED6OJX4VV', 'assemble_group' => array ( 0 => array ( 'nickname' => 'Jack', 'phone' => 15295892895, 'is_group' => 1, 'created_at' => 1544944181, 'assemble_id' => 'ED6OJX4VV', 'status' => 1, ), 1 => array ( 'nickname' => 'Jelly', 'phone' => 15295892895, 'is_group' => 0, 'created_at' => 1544944181, 'assemble_id' => 'ED6OJX4VV', 'status' => 1, ), ), ), )

preferences:
87.1 ms | 411 KiB | 5 Q