小编BLe*_*v80的帖子

我只需要显示JSON编码对象的一部分

嗨,我是PHP的新手,但已经成功地满足了我的要求:

我试图只显示JSON解码对象的一部分.我打电话给对象$Results.

我可以成功使用var_dump ($Results);,然后得到如下的完整结果:

object(stdClass)[2]
  public '0' => 
    object(stdClass)[3]
      public 'forename_1' => string 'JAMES' (length=5)
      public 'middle1_1' => string '' (length=0)
      public 'middle2_1' => string '' (length=0)
      public 'middle3_1' => string '' (length=0)
      public 'surname_1' => string 'TURNER' (length=7)      
  public 'Status' => int 100
Run Code Online (Sandbox Code Playgroud)

然后我使用以下代码将其插入表中:

<html>
<form id="client-details" action="/details.php" method="post">
  <table>
    <thead>
        <tr> 
            <th>First Name</th>
            <th>Surname</th>
             <th>Search</th>  
        </tr>
     </thead>
<?php foreach($Results as $o):?>
<tr>
  <td id="forename"><?= $o->forename_1 ?></td>
  <td id="surname"><?= $o->surname_1 ?></td>
  <td><button type="submit" >More Info</button></td> …
Run Code Online (Sandbox Code Playgroud)

php json object

6
推荐指数
1
解决办法
164
查看次数

标签 统计

json ×1

object ×1

php ×1