我正在尝试获取数组选项列表并将此列表插入params值,下面是输出应该是什么的示例。我正在使用wordpress并说我希望数组是所有页面或用户角色的列表。我有工程师和工作人员的地方FM角色这需要是基于wordpress中可用的用户角色的动态列表。
array(
"type" => "dropdown",
"holder" => "div",
"class" => "",
"heading" => __( "Select the type of user", "my-text-domain" ),
"param_name" => "type",
"group" => __( 'User', 'my-text-domain' ),
"value" => array(
'engineer' => 'engineer',
'fm' => 'fm'),
'save_always' => true,
"description" => __( "Pick a dropdown option.", "my-text-domain" )
),
如上所述我想在这里插入一个数组列表(my_array_values),但它们是动态的,所以需要知道如何输出返回到下面的格式,输出上面的格式?
array(
"type" => "dropdown",
"holder" => "div",
"class" => "",
"heading" => __( "Select the type of user", "my-text-domain" ),
"param_name" => "type",
"group" => __( 'User', 'my-text-domain' ),
"value" => array(
my_array_values),
'save_always' => true,
"description" => __( "Pick a dropdown option.", "my-text-domain" )
),
答案 0 :(得分:0)
简单如下:
$foo["value"] = array("engineer" => "engineer", "fm" => "fm");
答案 1 :(得分:0)
找到了答案,并认为我正在为数组添加一个数组。下面的作品!
$ foo = array('engineer'=>'engineer','fm'=>'fm');
array(
"type" => "dropdown",
"holder" => "div",
"class" => "",
"heading" => __( "Select the type of user", "my-text-domain" ),
"param_name" => "type",
"group" => __( 'User', 'my-text-domain' ),
"value" => $foo,
'save_always' => true,
"description" => __( "Pick a dropdown option.", "my-text-domain" )
),