0

I've listed all plugins and when I var_dump() it, I get this:

array(17) {
  ["advanced-custom-fields/acf.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(22) "Advanced Custom Fields"
    ["PluginURI"]=>
    string(36) "https://www.advancedcustomfields.com"
    ["Version"]=>
    string(6) "5.8.12"
    ["Description"]=>
    string(69) "Customize WordPress with powerful, professional and intuitive fields."
    ["Author"]=>
    string(13) "Elliot Condon"
    ["AuthorURI"]=>
    string(36) "https://www.advancedcustomfields.com"
    ["TextDomain"]=>
    string(3) "acf"
    ["DomainPath"]=>
    string(5) "/lang"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(22) "Advanced Custom Fields"
    ["AuthorName"]=>
    string(13) "Elliot Condon"
  }
  ["akismet/akismet.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(17) "Akismet Anti-Spam"
    ["PluginURI"]=>
    string(20) "https://akismet.com/"
    ["Version"]=>
    string(5) "4.1.6"
    ["Description"]=>
    string(279) "Used by millions, Akismet is quite possibly the best way in the world to protect your blog from spam. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key."
    ["Author"]=>
    string(10) "Automattic"
    ["AuthorURI"]=>
    string(41) "https://automattic.com/wordpress-plugins/"
    ["TextDomain"]=>
    string(7) "akismet"
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(17) "Akismet Anti-Spam"
    ["AuthorName"]=>
    string(10) "Automattic"
  }
  ["autoptimize/autoptimize.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(11) "Autoptimize"
    ["PluginURI"]=>
    string(24) "https://autoptimize.com/"
    ["Version"]=>
    string(5) "2.7.3"
    ["Description"]=>
    string(76) "Makes your site faster by optimizing CSS, JS, Images, Google fonts and more."
    ["Author"]=>
    string(23) "Frank Goossens (futtta)"
    ["AuthorURI"]=>
    string(24) "https://autoptimize.com/"
    ["TextDomain"]=>
    string(11) "autoptimize"
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(11) "Autoptimize"
    ["AuthorName"]=>
    string(23) "Frank Goossens (futtta)"
  }
  ["bbpress/bbpress.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(7) "bbPress"
    ["PluginURI"]=>
    string(19) "https://bbpress.org"
    ["Version"]=>
    string(5) "2.6.5"
    ["Description"]=>
    string(70) "bbPress is forum software with a twist from the creators of WordPress."
    ["Author"]=>
    string(24) "The bbPress Contributors"
    ["AuthorURI"]=>
    string(19) "https://bbpress.org"
    ["TextDomain"]=>
    string(7) "bbpress"
    ["DomainPath"]=>
    string(11) "/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(3) "4.7"
    ["RequiresPHP"]=>
    string(6) "5.6.20"
    ["Title"]=>
    string(7) "bbPress"
    ["AuthorName"]=>
    string(24) "The bbPress Contributors"
  }
  ["buddypress/bp-loader.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(10) "BuddyPress"
    ["PluginURI"]=>
    string(23) "https://buddypress.org/"
    ["Version"]=>
    string(5) "6.1.0"
    ["Description"]=>
    string(126) "BuddyPress adds community features to WordPress. Member Profiles, Activity Streams, Direct Messaging, Notifications, and more!"
    ["Author"]=>
    string(24) "The BuddyPress Community"
    ["AuthorURI"]=>
    string(23) "https://buddypress.org/"
    ["TextDomain"]=>
    string(10) "buddypress"
    ["DomainPath"]=>
    string(14) "/bp-languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(10) "BuddyPress"
    ["AuthorName"]=>
    string(24) "The BuddyPress Community"
  }
  ["classic-editor/classic-editor.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(14) "Classic Editor"
    ["PluginURI"]=>
    string(45) "https://wordpress.org/plugins/classic-editor/"
    ["Version"]=>
    string(3) "1.5"
    ["Description"]=>
    string(154) "Enables the WordPress classic editor and the old-style Edit Post screen with TinyMCE, Meta Boxes, etc. Supports the older plugins that extend this screen."
    ["Author"]=>
    string(22) "WordPress Contributors"
    ["AuthorURI"]=>
    string(44) "https://github.com/WordPress/classic-editor/"
    ["TextDomain"]=>
    string(14) "classic-editor"
    ["DomainPath"]=>
    string(10) "/languages"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(14) "Classic Editor"
    ["AuthorName"]=>
    string(22) "WordPress Contributors"
  }
  ["contact-form-7/wp-contact-form-7.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(14) "Contact Form 7"
    ["PluginURI"]=>
    string(25) "https://contactform7.com/"
    ["Version"]=>
    string(5) "5.1.9"
    ["Description"]=>
    string(54) "Just another contact form plugin. Simple but flexible."
    ["Author"]=>
    string(16) "Takayuki Miyoshi"
    ["AuthorURI"]=>
    string(31) "https://ideasilo.wordpress.com/"
    ["TextDomain"]=>
    string(14) "contact-form-7"
    ["DomainPath"]=>
    string(11) "/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(14) "Contact Form 7"
    ["AuthorName"]=>
    string(16) "Takayuki Miyoshi"
  }
  ["elementor/elementor.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(9) "Elementor"
    ["PluginURI"]=>
    string(87) "https://elementor.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash"
    ["Version"]=>
    string(6) "2.9.13"
    ["Description"]=>
    string(143) "The most advanced frontend drag & drop page builder. Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design."
    ["Author"]=>
    string(13) "Elementor.com"
    ["AuthorURI"]=>
    string(87) "https://elementor.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash"
    ["TextDomain"]=>
    string(9) "elementor"
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(9) "Elementor"
    ["AuthorName"]=>
    string(13) "Elementor.com"
  }
  ["gutenberg/gutenberg.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(9) "Gutenberg"
    ["PluginURI"]=>
    string(38) "https://github.com/WordPress/gutenberg"
    ["Version"]=>
    string(5) "8.4.0"
    ["Description"]=>
    string(85) "Printing since 1440. This is the development plugin for the new block editor in core."
    ["Author"]=>
    string(14) "Gutenberg Team"
    ["AuthorURI"]=>
    string(0) ""
    ["TextDomain"]=>
    string(9) "gutenberg"
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(3) "5.3"
    ["RequiresPHP"]=>
    string(3) "5.6"
    ["Title"]=>
    string(9) "Gutenberg"
    ["AuthorName"]=>
    string(14) "Gutenberg Team"
  }
  ["health-check/health-check.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(30) "Health Check & Troubleshooting"
    ["PluginURI"]=>
    string(43) "https://wordpress.org/plugins/health-check/"
    ["Version"]=>
    string(5) "1.4.4"
    ["Description"]=>
    string(44) "Checks the health of your WordPress install."
    ["Author"]=>
    string(27) "The WordPress.org community"
    ["AuthorURI"]=>
    string(43) "https://wordpress.org/plugins/health-check/"
    ["TextDomain"]=>
    string(12) "health-check"
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(30) "Health Check & Troubleshooting"
    ["AuthorName"]=>
    string(27) "The WordPress.org community"
  }
  ["hello.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(11) "Hello Dolly"
    ["PluginURI"]=>
    string(41) "http://wordpress.org/plugins/hello-dolly/"
    ["Version"]=>
    string(5) "1.7.2"
    ["Description"]=>
    string(295) "This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page."
    ["Author"]=>
    string(14) "Matt Mullenweg"
    ["AuthorURI"]=>
    string(13) "http://ma.tt/"
    ["TextDomain"]=>
    string(0) ""
    ["DomainPath"]=>
    string(0) ""
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(11) "Hello Dolly"
    ["AuthorName"]=>
    string(14) "Matt Mullenweg"
  }
  ["jetpack/jetpack.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(24) "Jetpack by WordPress.com"
    ["PluginURI"]=>
    string(19) "https://jetpack.com"
    ["Version"]=>
    string(5) "8.6.1"
    ["Description"]=>
    string(218) "Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users."
    ["Author"]=>
    string(10) "Automattic"
    ["AuthorURI"]=>
    string(19) "https://jetpack.com"
    ["TextDomain"]=>
    string(7) "jetpack"
    ["DomainPath"]=>
    string(11) "/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(24) "Jetpack by WordPress.com"
    ["AuthorName"]=>
    string(10) "Automattic"
  }
  ["plugin-load-filter/plugin-load-filter.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(18) "plugin load filter"
    ["PluginURI"]=>
    string(43) "https://celtislab.net/wp_plugin_load_filter"
    ["Version"]=>
    string(5) "3.3.0"
    ["Description"]=>
    string(102) "Dynamically activate the selected plugins for each page. Response will be faster by filtering plugins."
    ["Author"]=>
    string(17) "enomoto@celtislab"
    ["AuthorURI"]=>
    string(22) "https://celtislab.net/"
    ["TextDomain"]=>
    string(3) "plf"
    ["DomainPath"]=>
    string(10) "/languages"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(18) "plugin load filter"
    ["AuthorName"]=>
    string(17) "enomoto@celtislab"
  }
  ["custom-css-js/custom-css-js.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(5) "2.3.0"
    ["WC tested up to"]=>
    string(3) "4.1"
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(24) "Simple Custom CSS and JS"
    ["PluginURI"]=>
    string(44) "https://wordpress.org/plugins/custom-css-js/"
    ["Version"]=>
    string(6) "3.31.1"
    ["Description"]=>
    string(67) "Easily add Custom CSS or JS to your website with an awesome editor."
    ["Author"]=>
    string(14) "SilkyPress.com"
    ["AuthorURI"]=>
    string(26) "https://www.silkypress.com"
    ["TextDomain"]=>
    string(13) "custom-css-js"
    ["DomainPath"]=>
    string(11) "/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(24) "Simple Custom CSS and JS"
    ["AuthorName"]=>
    string(14) "SilkyPress.com"
  }
  ["woocommerce/woocommerce.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(11) "WooCommerce"
    ["PluginURI"]=>
    string(24) "https://woocommerce.com/"
    ["Version"]=>
    string(5) "4.2.2"
    ["Description"]=>
    string(63) "An eCommerce toolkit that helps you sell anything. Beautifully."
    ["Author"]=>
    string(10) "Automattic"
    ["AuthorURI"]=>
    string(23) "https://woocommerce.com"
    ["TextDomain"]=>
    string(11) "woocommerce"
    ["DomainPath"]=>
    string(16) "/i18n/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(11) "WooCommerce"
    ["AuthorName"]=>
    string(10) "Automattic"
  }
  ["wp-delay-load/wp-delay-load.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(13) "WP Delay Load"
    ["PluginURI"]=>
    string(25) "https://www.fixrunner.com"
    ["Version"]=>
    string(5) "1.0.0"
    ["Description"]=>
    string(89) "Great plugin to delay your plugins, scripts and assets in order to speed up your website."
    ["Author"]=>
    string(31) "FixRunner "
    ["AuthorURI"]=>
    string(25) "https://www.fixrunner.com"
    ["TextDomain"]=>
    string(3) "wdl"
    ["DomainPath"]=>
    string(10) "/languages"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(13) "WP Delay Load"
    ["AuthorName"]=>
    string(31) "FixRunner "
  }
  ["wp-fastest-cache/wpFastestCache.php"]=>
  array(16) {
    ["WC requires at least"]=>
    string(0) ""
    ["WC tested up to"]=>
    string(0) ""
    ["Woo"]=>
    string(0) ""
    ["Name"]=>
    string(16) "WP Fastest Cache"
    ["PluginURI"]=>
    string(46) "http://wordpress.org/plugins/wp-fastest-cache/"
    ["Version"]=>
    string(7) "0.9.0.7"
    ["Description"]=>
    string(40) "The simplest and fastest WP Cache system"
    ["Author"]=>
    string(9) "Emre Vona"
    ["AuthorURI"]=>
    string(34) "http://tr.linkedin.com/in/emrevona"
    ["TextDomain"]=>
    string(16) "wp-fastest-cache"
    ["DomainPath"]=>
    string(11) "/languages/"
    ["Network"]=>
    bool(false)
    ["RequiresWP"]=>
    string(0) ""
    ["RequiresPHP"]=>
    string(0) ""
    ["Title"]=>
    string(16) "WP Fastest Cache"
    ["AuthorName"]=>
    string(9) "Emre Vona"
  }
}

I need to dynamically get the first keys of every outer array see the image

This is dynamically created values and depends on installed plugins on the WordPress website. So I can not use $array["advanced-custom-fields/acf.php"]. You getting the point.

This is what I tried so far:

echo $array[0] but I get Notice: Undefined offset: 0

Also I tried this:

foreach ($arrays as $array) {
    echo $array[0];
}

But the error is the same as above.

Can someone help me with this?

Marko
  • 33
  • 5
  • Something like [array_keys()](https://www.php.net/manual/en/function.array-keys.php)? – brombeer Jul 09 '20 at 20:05
  • @Don'tPanic How? I tried `foreach ($arrays as $array) { echo reset($array); }` and only I get is 2.3.0. It is completely wrong. – Marko Jul 09 '20 at 20:09
  • 1
    @Marko sorry, I added that comment before I looked at the picture. I was thinking you wanted to get the value of the first key of each of the inner arrays. After looking at the picture it seems more like you're wanting each of the keys of the outer array. If that's the case, `foreach (array_keys($arrays) as $key) echo $key;` should work. If that's not the case, it seems I misunderstood again. – Don't Panic Jul 09 '20 at 20:24
  • @Don'tPanic Great, thanks! It works. You can add an answer. – Marko Jul 09 '20 at 20:28
  • It's okay, the linked answer covers it well. The top answer there uses `foreach($array as $key => $value)` and then echos the `$key`. I like to use `array_keys` instead because the unused `$value` variable annoys me, but either one is fine. Good luck with your project! – Don't Panic Jul 09 '20 at 20:34
  • @Don'tPanic Just one question. Since I already using `foreach ($arrays as $array) {}` to display and collect the necessary index, how to put this together with your solution? Can I get the keys of the outer array with my type of `foreach`? – Marko Jul 09 '20 at 20:44
  • Sure! If you're already doing it that way, just add the key to the loop definition like `foreach ($arrays as $key => $array)` Then you'll have both in the same loop. – Don't Panic Jul 09 '20 at 20:45
  • You're the best! – Marko Jul 09 '20 at 20:50

0 Answers0