In Wordpress I'm trying to create a metabox script from scratch to better understand both Wordpress and PHP.
I'm having some problems with a for each loop on a multidimensional array though. I'm using PHP5.
This is the array:
$meta_box = array();
$meta_box[] = array(
'id' => 'monitor-specs',
'title' => 'Monitor Specifications',
'context' => 'normal',
'priority' => 'default',
'pages' => array('monitors', 'products'),
'fields' => array(
array(
'name' => 'Brand',
'desc' => 'Enter the brand of the monitor.',
'id' => $prefix . 'monitor_brand',
'type' => 'text',
'std' => ''
)
)
);
And this is the for each loop:
foreach ($meta_box['pages'] as $post_type => $value) {
add_meta_box($value['id'], $value['title'], 'je_format_metabox', $post_type, $value['context'], $value['priority']);
}
What I'm trying to do is loop through the keys in the 'pages' array which is an array inside the 'meta_box' array and at the same time be able to use the key values of the 'meta_box' array.
Do I need to nest some for each loops?
Would be grateful for some pointers in the right direction so I can solve this.