简体   繁体   English

如何回显stdClass对象数组的数组值

[英]How to echo an stdClass Object Array's array values

I have an array within an STDClass object as my select options. 我在STDClass对象中有一个数组作为选择选项。 I cannot understand how to echo its values. 我不明白如何回应其价值观。

var $fields = array( array(
   'name'   => 'icon',
   'type'   => 'select',
   'items' => array(0 => 'news', 1 => 'technology', 2 => 'products'),
    ),  
);

Then within the widget function: 然后在小部件功能内:

function widget($args, $instance)
{
$inst = (object) wp_parse_args($instance, array(
        'icon'              => '',
        'title'             => '',
        'display_title'     => '',
        'content'           => '',
        'link_text'         => '',
    ));
}

Within this function echo $inst->icon; 在此函数中, echo $inst->icon; gives me the key. 给我钥匙。 How do I get the value? 我如何获得价值?

Have you tried the 'old' array notation instead of the arrow? 您是否尝试过使用“旧”数组符号而不是箭头?

echo $inst['icon'] ; echo $inst['icon'] ;

Source : that is how they seem to print values in this documentation : http://codex.wordpress.org/Function_Reference/wp_parse_args 来源 :这就是它们在本文档中显示值的方式: http : //codex.wordpress.org/Function_Reference/wp_parse_args

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM