Hi, I am new to PHP, but I succeeded:
I am trying to display only one part of a decoded JSON object. I called the $Results object.
I can successfully use var_dump ($Results); and then get the full results as follows:
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
Then I insert this into the table using the following code:
<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> </tr> <?php endforeach; ?> </table></form> </html>
There is a problem. When I show the results, I get the following error: "Note: attempt to get a non-object property .."
It looks like I'm trying to start the public 'Status' => int 100 object.
So my question is: How can I either stop the table from trying to fill out this "status", or how can I completely ignore it?
EDIT: If I wanted to be able to get the results from json_decode as an associative array and not as objects ... would this help me ignore the "status" array / object?
source share