How to output and StdClass object in a table?

Hi,

Sorry in advance for the kind of question. I am still a newbee when it comes to POO and 'm searching since hours, trying to follow many tutorials, but i can’t find how to output the array in a StdClass in an html table :slight_smile: I tried to follow examples from many tutorials, but i always come with “Uninitialized string offset” or “Trying to get property of non-object in”.

I’m trying to learn how to develop a web interface based on an API (whmcs in this case). I saw a class on github may help me a lot with this work.

I saw this class :

i’m trying to figure out how to use this class : https://github.com/dotblock/whmcs-php

I’m adding this code, as per the readme file :

[php]

<?php include_once 'lib/whmcs.php'; define('WHMCS_URL', 'http://example.com/includes/api.php'); define('WHMCS_USERNAME', 'someusername'); define('WHMCS_PASSWORD', 'c4ca4238a0b923820dcc509a6f75849b'); // md5 hash var_dump(WHMCS_Client::get_clients_details(array('clientid' => '1'))); [/php] It return me an std object : [php]object(stdClass)#1 (46) { ["result"]=> string(7) "success" ["userid"]=> string(3) "634" ["id"]=> string(3) "634" ["firstname"]=> string(4) "DummyData" ["lastname"]=> string(4) "Test" ["fullname"]=> string(9) "DummyData Test" ["companyname"]=> string(5) "test2" ["email"]=> string(23) "[email protected]" ["address1"]=> string(10) "122 DummyData" ["address2"]=> string(0) "" ["city"]=> string(8) "DummyData" ["fullstate"]=> string(6) "DummyData" ["state"]=> string(6) "DummyData" ["postcode"]=> string(6) "DummyData" ["countrycode"]=> string(2) "DummyData" ["country"]=> string(2) "DummyData" ["statecode"]=> string(2) "DummyData" ["countryname"]=> string(6) "DummyData" ["phonecc"]=> string(1) "1" ["phonenumber"]=> string(10) "8886327730" ["phonenumberformatted"]=> string(13) "+1.5555555555" ["billingcid"]=> string(1) "0" ["notes"]=> string(0) "" ["password"]=> string(38) "cf3b36a8cc33456567yuae8c4b2c:HeJcI" ["twofaenabled"]=> string(0) "" ["currency"]=> string(1) "1" ["defaultgateway"]=> string(0) "" ["cctype"]=> string(0) "" ["cclastfour"]=> string(0) "" ["securityqid"]=> string(1) "2" ["securityqans"]=> string(21) "HTjs56rerw56%?$R" ["groupid"]=> string(1) "0" ["status"]=> string(8) "Inactive" ["credit"]=> string(4) "0.00" ["taxexempt"]=> string(0) "" ["latefeeoveride"]=> string(0) "" ["overideduenotices"]=> string(0) "" ["separateinvoices"]=> string(0) "" ["disableautocc"]=> string(0) "" ["emailoptout"]=> string(1) "0" ["overrideautoclose"]=> string(1) "0" ["language"]=> string(0) "" ["lastlogin"]=> string(80) "Date: 18/08/2014 14:52[/php] I never had to work with an StdClass before. :-X I know these are anonymous classes, but that's pretty much it. :P I would like to learn a little, so i am trying to make this work. Someone can tell me how i can echo only those values in a table ? : firstname, lastname, companyname, address1, city, fullstate, postcode ...just need a quick example to get back on the road :) thank you in advance!

Looks like instead of var dump, you do "$client = ", and then

$userid = $client->userid;

Sponsor our Newsletter | Privacy Policy | Terms of Service