php中的多维数组循环

php中的多维数组循环,php,wordpress,Php,Wordpress,我需要列出在wordpress中有更新可用的插件。理想的情况是: 插件名称“当前版本”可用更新版本 e、 g.“real media library lite”“4.9.0”“4.11.0” 到目前为止,我得到了我需要的数据(除了当前版本),如下所示: 其输出如下: array(3) { ["real-media-library-lite/index.php"]=> object(stdClass)#8563 (12) { ["id&q

我需要列出在wordpress中有更新可用的插件。理想的情况是: 插件名称“当前版本”可用更新版本 e、 g.“real media library lite”“4.9.0”“4.11.0”

到目前为止,我得到了我需要的数据(除了当前版本),如下所示:

其输出如下:

array(3) {
    ["real-media-library-lite/index.php"]=> object(stdClass)#8563 (12) {
        ["id"]=> string(37) "w.org/plugins/real-media-library-lite"
        ["slug"]=> string(23) "real-media-library-lite"
        ["plugin"]=> string(33) "real-media-library-lite/index.php"
        ["new_version"]=> string(6) "4.11.0"
        ["url"]=> string(54) "https://wordpress.org/plugins/real-media-library-lite/"
        ["package"]=> string(66) "https://downloads.wordpress.org/plugin/real-media-library-lite.zip"
        ["icons"]=> array(2) {
            ["2x"]=> string(76) "https://ps.w.org/real-media-library-lite/assets/icon-256x256.gif?rev=2293211"
            ["1x"]=> string(76) "https://ps.w.org/real-media-library-lite/assets/icon-128x128.gif?rev=2293211"
        }
        ["banners"]=> array(2) {
            ["2x"]=> string(79) "https://ps.w.org/real-media-library-lite/assets/banner-1544x500.png?rev=2251436"
            ["1x"]=> string(78) "https://ps.w.org/real-media-library-lite/assets/banner-772x250.png?rev=2251436"
        }
        ["banners_rtl"]=> array(0) {
        }
        ["tested"]=> string(3) "5.6"
        ["requires_php"]=> string(5) "7.0.0"
        ["compatibility"]=> object(stdClass)#8555 (0) {
        }
    }
    ["advanced-custom-fields-pro/acf.php"]=> object(stdClass)#8557 (8) {
        ["slug"]=> string(26) "advanced-custom-fields-pro"
        ["plugin"]=> string(34) "advanced-custom-fields-pro/acf.php"
        ["new_version"]=> string(5) "5.9.3"
        ["url"]=> string(36) "https://www.advancedcustomfields.com"
        ["tested"]=> string(5) "5.5.3"
        ["package"]=> string(0) ""
        ["icons"]=> array(1) {
            ["default"]=> string(63) "https://ps.w.org/advanced-custom-fields/assets/icon-256x256.png"
        }
        ["banners"]=> array(2) {
            ["low"]=> string(77) "https://ps.w.org/advanced-custom-fields/assets/banner-772x250.jpg?rev=1729102"
            ["high"]=> string(78) "https://ps.w.org/advanced-custom-fields/assets/banner-1544x500.jpg?rev=1729099"
        }
    }
    ["real-media-library/index.php"]=> object(stdClass)#8560 (7) {
        ["slug"]=> string(18) "real-media-library"
        ["new_version"]=> string(6) "4.11.0"
        ["package"]=> NULL
        ["id"]=> int(0)
        ["url"]=> string(47) "https://devowl.io/wordpress-real-media-library/"
        ["tested"]=> string(3) "5.6"
        ["plugin"]=> string(28) "real-media-library/index.php"
    }
}

我似乎不知道如何在这个数组上循环并输出“slug”和“new_version”,见鬼,我甚至不能动态输出数组第一维的值。 到目前为止,我只能像这样获得我需要的数据:

$update_plugins = get_site_transient( 'update_plugins' );
$slug = $update_plugins->response;
 print_r($slug["real-media-library-lite/index.php"]->slug);

但是我需要动态地输出数据。非常感谢您的帮助。

只需在响应数组上迭代并输出
slug
新版本
属性,即可使用
foreach
循环完成:

foreach($update_plugins->response as $plugin_name => $plugin_object) {
    var_dump($plugin_object->slug);
    var_dump($plugin_object->new_version);
}
foreach($update_plugins->response as $plugin_name => $plugin_object) {
    var_dump($plugin_object->slug);
    var_dump($plugin_object->new_version);
}