first(['nickname', 'avatar']); if ($info) { $data['nickname'] = $info->nickname; $data['avatar'] = $info->avatar; } } } $arr = [ "id" => 0, "source" => 1, "msg_type" => 1, "user_id" => 0, "receive_id" => 0, "content" => '', "is_revoke" => 0, // 发送消息人的信息 "nickname" => "", "avatar" => "", // 不同的消息类型 "file" => [], "code_block" => [], "forward" => [], "invite" => [], "created_at" => "", ]; return array_merge($arr, array_intersect_key($data, $arr)); } }