如何从数组中获取WP_Widget_Archives,
这是我的数组:
$control = Array
(
[name] => Archives
[id] => archives-6
[callback] => Array
(
[0] => WP_Widget_Archives Object
(
[id_base] => archives
[name] => Archives
[widget_options] => Array
(
[classname] => widget_archive
[description] => A monthly archive of your site’s Posts.
)
[control_options] => Array
(
[id_base] => archives
)
[number] => 8
[id] => archives-8
[updated] =>
[option_name] => widget_archives
)
[1] => form_callback
)
[params] => Array
(
[0] => Array
(
[number] => 6
)
)
[width] => 250
[height] => 200
[id_base] => archives
)我已经尝试过这段代码
`echo '<pre>'; print_r(array_keys($control['callback'])); echo '</pre>';`但是我得到的结果是这样的
Array
(
[0] => 0
[1] => 1
)我想结果会是这样的
$result = Array
(
[0] => WP_Widget_Archives Object
[1] => form_callback
)因此,我可以为get WP_Widget_Archives编写$result[0],请帮助我,并感谢您的帮助:)
发布于 2016-07-04 09:55:47
可能您误解了array_key函数。它会给你数组的键,而不是值。在你的例子中,你需要的值是一个'WP_Widget_Archives‘对象,所以你可以直接使用$control’‘callback’。
https://stackoverflow.com/questions/38175911
复制相似问题