1
我有下面的代碼:如何在數組中添加2個也是數組的變量?
這裏我聲明的代碼用於獲取類別名稱和蛞蝓
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'taxonomy' => 'category'
);
$categories = get_categories($args);
$categories_name = array(); // here i get the category name
$categories_ids = array(); // here i get the category slug
foreach($categories as $category){
$categories_name[] = $category->name;
$categories_ids[] = $category->slug;
}
這裏是我的後端迴盪着的類別名稱爲用戶設置選擇
$this->settings['categoriesmain3'] = array(
'section' => 'general',
'title' => __('Select Right Block Category'),
'desc' => __('Here you can select the main category for main right block.'),
'type' => 'select',
'std' => '',
'choices' => array('$categories_name' => '$categories_ids') //I am trying to do
);
$settings = get_option('mytheme_options');
$my_choices_cat3 = $settings['categoriesmain3'];
我試圖在choices =>
代碼array('$categories_name' => '$categories_ids')'
添加,但它不喜歡的工作。在我手動添加選擇字段的例子中,我有'choices' => array('Choice 1' => 'choice1', 'Choice 2' => 'Choice 2')
,那麼我想添加一個動態列表的choices
元素的正確語法是什麼?
這正是我一直在尋找的感謝。 – Adrian