dongshan1959 2015-12-08 15:53
浏览 59

访问数组内部对象

I've currently got a variable called $Listings, which outputs this when var_dump($Listing);:

object(xreceiver_listing)#15 (11) { 
["table":protected]=> string(24) "perch_xreceiver_listings" 
["pk":protected]=> string(5) "XMLID" 
["api":protected]=> object(PerchAPI)#10 (3) { 
    ["app_id"]=> string(13) "tfd_xreceiver" 
    ["version"]=> float(1) 
    ["Lang":"PerchAPI":private]=> object(PerchAPI_Lang)#11 (5) { 
        ["lang_dir"]=> string(106) "/var/www/vhosts/thirdfloordigital.net/development.thirdfloordigital.net/cms/addons/apps/tfd_xreceiver/lang" 
        ["lang_file"]=> string(116) "/var/www/vhosts/thirdfloordigital.net/development.thirdfloordigital.net/cms/addons/apps/tfd_xreceiver/lang/en-gb.txt" 
        ["lang"]=> string(5) "en-gb" 
        ["translations":"PerchAPI_Lang":private]=> array(31) { 
            ["lang"]=> string(5) "en-gb" 
            ["Sample"]=> string(6) "Sample" 
            ["Sample app"]=> string(10) "Sample app" 
            ["There are currently no things. Why not add one?"]=> string(47) "There are currently no things. Why not add one?" 
            ["In the sidebar you should try and give the user guidance and tips."]=> string(66) "In the sidebar you should try and give the user guidance and tips." 
            ["For content editing pages, presume the user is non-technical editor using the software."]=> string(87)    "For content editing pages, presume the user is non-technical editor using the software." 
            ["For configuration pages, presume the user is the web designer who is setting up the site."]=> string(89)  "For configuration pages, presume the user is the web designer who is setting up the        site." 
            ["Add/Edit"]=> string(8) "Add/Edit" 
            ["Add Thing"]=> string(9) "Add Thing" 
            ["Listing all Sample Things"]=> string(25) "Listing all Sample Things" 
            ["Edit"]=> string(4) "Edit" 
            ["Thing / Create New Thing"]=> string(24) "Thing / Create New Thing" 
            ["Thing details"]=> string(13) "Thing details" 
            ["Title"]=> string(5) "Title" 
            ["Date"]=> string(4) "Date" 
            ["Save"]=> string(4) "Save" 
            ["or"]=> string(2) "or" 
            ["Cancel"]=> string(6) "Cancel" 
            ["Your thing has been successfully created. Return to %sthing listing%s"]=> string(69) "Your thing has been successfully created. Return to %sthing listing%s" 
            ["Thing / Edit Thing"]=> string(18) "Thing / Edit Thing" 
            ["All"]=> string(3) "All" 
            ["Delete"]=> string(6) "Delete" 
            ["Delete Thing"]=> string(12) "Delete Thing" 
            ["Delete a thing here."]=> string(20) "Delete a thing here." 
            ["Deleting a Thing"]=> string(16) "Deleting a Thing" 
            ["Are you sure you wish to delete the thing %s?"]=> string(45) "Are you sure you wish to delete the thing%s?" 
            ["Example setting"]=> string(15) "Example setting" 
            ["XReceiver"]=> string(9) "XReceiver" 
            ["There are currently no listings. Why not add one?"]=> string(49) "There are currently no listings. Why not add one?" 
            ["Add Listing"]=> string(11) "Add Listing" 
            ["All Listings"]=> string(12) "All Listings" 
        } 
        ["to_add":"PerchAPI_Lang":private]=> array(0) { 
        } 
    } 
} 
["db":protected]=> object(PerchDB_MySQL)#3 (4) { 
    ["link":"PerchDB_MySQL":private]=> object(PDO)#5 (0) { 
    } 
    ["errored"]=> bool(false) 
    ["error_msg"]=> bool(false) 
    ["dsn"]=> string(43) "mysql:host=localhost;dbname=developmenttfd;" 
} 
["details":protected]=> array(28) { 
    ["XMLID"]=> string(1) "5" 
    ["command"]=> string(3) "add" 
    ["username"]=> string(8) "jimgreen" 
    ["password"]=> string(8) "p455w0rd" 
    ["contact_name"]=> string(11) "Sean Greeen" 
    ["contact_email"]=> string(13) "jim@green.com" 
    ["contact_telephone"]=> string(12) "066 3413 930" 
    ["contact_url"]=> string(13) "www.green.com" 
    ["days_to_advertise"]=> string(2) " 7" 
    ["application_email"]=> string(32) "jim.12345.123@green.aplitrak.com" 
    ["application_url"]=> string(39) "http://www.url.com/ad.asp?adid=12345123" 
    ["job_reference"]=> string(6) "abc123" 
    ["job_title"]=> string(13) "Web Developer" 
    ["job_type"]=> string(9) "Permanent" 
    ["job_id"]=> string(14) "abc123_1234567" 
    ["job_duration"]=> string(9) "Permanent" 
    ["job_startdate"]=> string(4) "ASAP" 
    ["job_skills"]=> string(19) "VB, C++, PERL, Java" 
    ["job_description"]=> string(32) "This is the detailed description" 
    ["job_location"]=> string(6) "London" 
    ["job_industry"]=> string(9) "Aerospace" 
    ["salary_currency"]=> string(3) "gbp" 
    ["salary_from"]=> string(5) "30000" 
    ["salary_to"]=> string(5) "33000" 
    ["salary_per"]=> string(5) "annum" 
    ["salary_benefits"]=> string(17) "Bonus and Pension" 
    ["salary"]=> string(51) "£30000 - £33000 per annum + Bonus and Pension" 
    ["listingDynamicFields"]=> NULL 
} 
["index_table":protected]=> bool(false) 
["event_prefix":protected]=> bool(false) 
["suppress_events"]=> bool(true) 
["can_log_resources":protected]=> bool(true) 
["modified_date_column":protected]=> bool(false) 
["pk_is_int":protected]=> bool(true) 
}

I need to access the details:protected array and grab information from there.

So far, I've tried:

`$variable = $classAccess->{'PerchAPI'};var_dump($variable);`

which returns NULL.

Any tips on accessing this array? Thanks.

  • 写回答

1条回答 默认 最新

  • dou9022 2015-12-09 09:05
    关注

    For anybody reading: This problem was resolved, with help from @JonStirling (comments).

    $xreceiver_info = $Listing->getDetails();
    <?php print_r($xreceiver_info['job_title']);?>
    

    $Listing is the variable that was putting out the block of code in the OP, and I dropped the getDetails() getter into the xreceiver_listing class, as Jon suggested.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!