So I have an array such as this:
$style = array(
'css' => array(
'name' => array('core-css', 'babababa'),
'path' => array(get_bloginfo('stylesheet_url'), get_template_directory_uri() . '/bababa.css')
),
'js' => array(
'name' => array('core-css', 'babababa'),
'path' => array(get_bloginfo('stylesheet_url'), get_template_directory_uri() . '/bababa.css')
)
);
I can walk through in this fashion:
function load_css(){
foreach($style as $key => $value){
var_dump($key);
}
}
Now the var_dump will return:
string(3) "css" string(2) "js" string(3) "css" string(2) "js"
The issue is that if I do var_dump($key[‘css]) or ‘js’ I get an illegal offset error…..
I need to check for both so I assumed doing:
if(isset($key['css']) && $key['css']){}
and then
if(isset($key['js']) && $key['js']){}
But alas it doesn’t work…..
Can some one please tell me what I am doing wrong? I have walked through arrays like this countless times…. >.<
It is proper PHP behaviour
will output
To get to name and path use: