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.
The
patharray is not apart of thenamearray, and should look something like:Or, you could always change the structure of your array: