"Trying to get property of non-object" in SOAP PHP - not sure why this error is occuring -
hope guys can me... still new @ php , struggling display parts of object/array set of results. getting following result $results soap webservice:
`object(stdclass)[9] public 'summary' => object(stdclass)[2] public 'id' => string '1096408402' (length=10) public 'ikey' => string '1440010962' (length=10) public 'address' => object(stdclass)[4] public 'forename' => string 'test' (length=4) public 'surname' => string 'tester' (length=6) public 'dob' => string '0000-00-00' (length=10) public 'telephone' => string 'unavailable' (length=11) public 'occupants' => array (size=3) 0 => object(stdclass)[12] ... 1 => object(stdclass)[13] ... 2 => object(stdclass)[14] ... 3 => object(stdclass)[15] ... now attempting put data table format.
i have been successful in creating table using foreach on section marked occupants. calling occupants follows: $occupants = ($results->address->occupants); , data extracted , populated table using code (not relevent question).
my problem when try , same summary or address doesnt work: error "trying property of non-object"
i have tried $summary = $results->summary , $summary = $results['summary'] , neither works.
what want run <?php $summary = ($results->summary);foreach($summary $person):?> , insert table follows: <td><?=$person->id?></td>
so idea why error? dont think in foreach aspect...?
normally, should "summary" object with:
$summary = $results->summary in case $summary object 2 properties: "id" , "ikey". if iterate on $summary foreach, value of $person have value of $summary->id in first loop iteration , value of $summary->ikey in second loop iteration. both $summary->id , $summary->ikey strings , therefore non-objects, think why error.
suppose want do this:
$summary = $results->summary; foreach ($summary $value) echo "<td>$value</td>"; this should output (for given example):
<td>1096408402</td><td>1440010962</td> for more information object iteration, recommend: http://php.net/manual/en/language.oop5.iterations.php
Comments
Post a Comment