我的代码是这样的。
$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();
有什么办法吗?感谢您的关注。
尝试
$temp = explode(",",$stemp[0]->hasil);
print_r($temp);
因为您的数组是对象的多维数组。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句