Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:43:21+00:00 2026-06-15T01:43:21+00:00

So I am having issues understanding how to iterate over an array that looks

  • 0

So I am having issues understanding how to iterate over an array that looks as such in php:

 $styles = array(
   'css' => array(
       'name' => array(
          'core-css', 
          'bootstrap-css',
          'bootstrap-responsive-css'
        ),
       'path' => array(
           get_bloginfo('stylesheet_url'), 
           get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css',
           get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.responsive.min.css'
        ),
    ),
 );

Essentially this styles gets passed to a constructor of a class which then iterates over the array in a method that looks like this (note this array is stored class level in a protected value called _options, hence the $this->_options in the following code:

foreach ( $this->_options as $key => $value ) {
    // load all the css files
    if (isset ( $this->_options ['css'] )) {
        foreach ( $value ['name'] as $name ) {
            foreach ( $value ['path'] as $path ) {
                wp_enqueue_style ( $name, $path );
            }

        }
     }
}

This will spit out something like:

  • core-css style.css
  • core-css bootstrap
  • core-css bootstrap-responsive

.

The problem should be clear right now, the name never changes and I think it has something to do with how I am iterating over the array of, essentially, arrays.

So your help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:43:22+00:00Added an answer on June 15, 2026 at 1:43 am

    The path array is not apart of the name array, and should look something like:

    foreach ( $this->_options as $key => $value ) {
        // load all the css files
        if (isset ( $this->_options ['css'] )) {
            foreach ( $value ['path'] as $k=>$path ) {
                wp_enqueue_style ( $value['name'][$k], $path );
            }
         }
    }
    

    Or, you could always change the structure of your array:

    $styles = array(
        'css' => array(
            array(
                'name'=>'core-css',
                'path'=>get_bloginfo('stylesheet_url')
            ),
            array(
                'name'=>'bootstrap-css',
                'path'=>get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css'
            ),
            array(
                'name'=>'bootstrap-responsive-css',
                'path'=>get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.responsive.min.css'
            )
        )
    );
    
    foreach($this->_options as $key => $value){
        if (isset ( $this->_options ['css'] )) {
            foreach($this->_options ['css'] as $k=>$v){
                 wp_enqueue_style ( $v['name'], $v['path'] );
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues creating, and understanding how to create a core data model
I'm having serious issues understanding PHP classes from a book. They seem very difficult.
I'm having some issues in understanding the CSS numeric attributes in percents. In this
I'm having some issues understanding how to reference new browser windows after opening them.
I am having issues with understanding how to make this happen. Basically we have
Hi I'm having some issues understanding how MVC 3 and razor work. Basically, I
Having issues with Twitter Bootstrap responsive navigation. The best way to explain this is
I am having issues understanding how std::set (or std::map etc) identify unique keys. The
Trying to get some basic understanding of console functionalities. I am having issues so
I'm having issues getting arrays to stick within a foreach loop. $sites = array($siteOne,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.