$playersArray = DB::table('sign_up')
->select('user_id', 'nickname')
->where('order_id', '=', $request->id)
->where('nickname', '<>', '')
->get()
->toarray();
$playersObj = \array_combine(array_column($playersArray, 'user_id'), \array_column($playersArray, 'nickname'));
PHP将数据表里的两个字段映射成对象的键和值
发布时间 2023-11-25 16:04:23作者: 小馬過河﹎