例如,我有以下代碼:如何在有條件的數組中包含數組?
<?php
$options = array(
array(
"type" => "section",
"icon" => "acera-icon-preference",
"title" => "General Settings",
"id" => "general",
"expanded" => "true"
),
array(
"under_section" => "ajax_login",
"type" => "checkbox",
"name" => "Who's Online Options",
"id" => array("tigu_whosonline_list", "tigu_whosonline_avatar"),
"display_checkbox_id" => "tigu_show_whosonline",
"img_desc" => "",
"options" => array("Who's Online List", "Who's Online Avatars"),
"desc" => "",
"default" => array("checked", "checked")
));
?>
有一個以上陣列的機器,但我縮短的代碼,以節省空間。現在的問題是: 我怎麼能包括在條件如果 somethink這樣的代碼只是將下面的代碼
array(
"type" => "section",
"icon" => "acera-icon-preference",
"title" => "General Settings",
"id" => "general",
"expanded" => "true"
),
(即出現錯誤):
if(function_exists('bp_is_active')):
array(
"type" => "section",
"icon" => "acera-icon-preference",
"title" => "General Settings",
"id" => "general",
"expanded" => "true"
),
endif;
bp_is_active它檢查功能的BuddyPress插件已安裝。只有在BuddyPress插件已安裝的情況下,我需要在我的wp管理面板上顯示該代碼。
謝謝!
你嘗試,如果'if'條件爲真創建陣列? – egig
不,你能更具體嗎? –
是不是說你在任何情況下都創建了$ options,但是隻有當函數bp_is_active存在時纔想添加帶有「type」=>「section」的數組作爲第一個元素?現在你的問題很混亂。 –