我想用foreach iin php显示json对象,但出现错误
我有一个json,想显示name
并获取错误警告:第50行的C:\ xampp \ htdocs \ webar \ app \ views \ home \ index.php中为foreach()提供的参数无效
stdClass Object
(
[result_code] => Success
[transaction_id] => 64401abaab3147758f726f81d49b560a
[target_record] => stdClass Object
(
[target_id] => f248175c2a6f4bcf9d9df6fe3e367ab5
[active_flag] => 1
[name] => markerbasil
[width] => 1
[tracking_rating] => 5
[reco_rating] =>
)
[status] => success
)
这是我的模特
public function index()
{
$data['isi'] = $this->model('GetTarget')->execGetTarget();
$this->view('templates/header');
$this->view('home/index', $data);
$this->view('templates/footer');
}
这是我的观点
<td>
<?php foreach( $data['isi']->target_record->name as $raw) { ?>
<?php echo $raw ?>
<?php } ?>
</td>