错误在Laravel中爆炸

Mading Ne

我的代码是这样的。

$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();

有什么办法吗?感谢您的关注。

西克帕蒂(Hikmat Sijapati)

尝试

$temp = explode(",",$stemp[0]->hasil); 
print_r($temp);

因为您的数组是对象的多维数组。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章