我WhereIn()在 Laravel 中使用方法來獲取各種“id”,但問題是我得到的數據是這樣的["6,19"],我期望的是一個沒有雙引號的數字數組。我得到的數據來自 varchar 字段,所以它作為 varchar 出現,現在我需要將其更改為 [6,19] 而不用雙引號。請指導我這樣做。該whereIn方法僅支持帶數字的數組。public function getusers($id){ $users = User::where('member_id', $id)->get(); foreach($users as $user) { $s = $user->path; $s = str_replace('/', ',', $s); //this gives 6,19 and if i wrap that with [] it gives us ["6,19"]. return $usergs = User::whereIn("id", [$s])->get(); //[$s] gives like ["6,19"] -but i need to change that as [6,19] (array not string) }}
- 1 回答
- 0 關注
- 406 瀏覽
添加回答
舉報
0/150
提交
取消