I am trying to create an array using foreach which is used inside an another array.
$team = array();
foreach ($items as $item) {
$team[] = array($item->post_title => $item->post_title, );
}
print_r($team);
$meta_boxes[] = array(
'title' => __( 'Team', 'meta-box' ),
'fields' => array(
array(
'name' => __( 'Select', 'meta-box' ),
'options' => $team,
),
)
);
The options array should be in the format of
'options' => array(
'value1' => ('Label1'),
'value2' => ('Label2'),
),
The print_r output is
Array (
[0] => Array ( [Jessi] => Jessi )
[1] => Array ( [Adam] => Adam )
[2] => Array ( [Babu] => Babu )
)
I am getting output as Array,Array,Array in selectbox for which I am trying to use this for. How do I fix this?
Thanks