【发布时间】:2017-01-13 08:57:54
【问题描述】:
我的代码是这样的。
$idwisa = "288";
$stemp = DB::table('t_hasil_temp')
->select('hasil')
->where('id', $idwisa)
->get();
当print_r($stemp); 我得到Array ( [0] => stdClass Object ( [hasil] => 20,24,22,26 ) ) 而hasil 是一个字符串
我想将hasil 转换为数组,我尝试这样。问题出在explode。
$temp = explode(",",$stemp->hasil); // error Trying to get property of non-object
或
$temp = explode(",",$stemp); // error explode() expects parameter 2 to be string, array given
因为之后我会像这样使用$temp。
$temps = Objek::whereIn('id',$temp)->get();
有什么解决办法吗?感谢您的关注。
【问题讨论】:
标签: php mysql sql laravel laravel-5.2