我将如何在 CodeIgniter 中打印结果?

How will i print the result in view in CodeIgniter?

我正在尝试在 controller.This 中作为数组返回的视图中的结果是使用 [=20= 的 api 调用的结果]json。 我需要在视图中显示结果。有为了显示它而集成的设计。 我怎么能在 CodeIgniter 中做到这一点?

函数调用:

 $data['nearme_values'] = $this->swsdk->nearMe($lat, $lon, $radius, $page, $size);

这是函数调用的var_dumb结果。

stdClass Object
 (   [content] => Array 
    ( [0] => stdClass Object 
        ( [id] => 1 [name] => Make America Great 
          [screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479113014667.jpg
          [type] => PUBLIC [status] => RECORDED [userId] => 1 [userHandle] => abhilekh 
          [channelId] => 1 [channelName] => Sports [likes] => 0 [views] => 0 
          [liveViewers] => 0 
       ) 
      [1] => stdClass Object 
        ( [id] => 2 [name] => Make America Great 
          [screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479110563909.jpg 
          [type] => PUBLIC [status] => RECORDED [userId] => 1 [userHandle] => abhilekh 
          [channelId] => 2 [channelName] => Politics [likes] => 0 [views] => 0 
          [liveViewers] => 0 
       ) 
      [2] => stdClass Object 
        ( [id] => 3 [name] => Make America Great 
          [screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/streamSShot/stream-1479109601008.jpg 
          [type] => PUBLIC [status] => RECORDED [userId] => 2 [userHandle] => sudhanshu 
          [channelId] => 3 [channelName] => Fun [likes] => 0 [views] => 0 
          [liveViewers] => 0            
      ) 
      [3] => stdClass Object 
        ( [id] => 4 [name] => Make America Great 
          [screenShotUrl] => http://52.77.190.221/SW/speaker_wire_images/profiles/pic-130.jpg 
          [type] => PUBLIC [status] => RECORDED [userId] => 2 [userHandle] => sudhanshu 
          [channelId] => 4 [channelName] => Art [likes] => 0 [views] => 0 
          [liveViewers] => 0 
      ) 
    ) [last] => 1 [totalPages] => 1 [totalElements] => 4 
      [numberOfElements] => 4 [sort] => [first] => 1 
      [size] => 10 [number] => 0 
 )

我是 CodeIgniter 的新手。请支持示例代码。

如果您要以 API 的身份调用,则无需显示。

在controller的方法中这样回显即可。

$nearme_values = $this->swsdk->nearMe($lat,$lon,$radius,$page,$size);
echo json_encode($nearme_values);

正在视图中显示。

// in Controller.
    $data['nearme_values'] = $this->swsdk->nearMe($lat, $lon, $radius, $page, $size);
    $this->load->view('ur_view_file', $data);


// in view
foreach ($nearme_values->content as $nearme) {
            echo $nearme->id .' / '. $nearme->screenShotUrl .' / '. $nearme->type .'<br>';
        }