我發現了一個「非法偏移類型」此陣:PHP:數組可以有一個數組作爲鍵值對中的鍵嗎?
public static $CATS_AND_TYPES = array(
// Statement Administration
array(self::CAT_STATEMENT_ADMIN => "Document Administration") => array(
self::TYPE_STATEMENTS_LOADED => "Documents Loaded",
self::TYPE_STATEMENTS_REMOVED => "Documents Removed"
),
// Cron Jobs
array(self::CAT_CRON_JOBS => "Cron Jobs") => array(
self::TYPE_CRON_BULLETIN_RUN => "Bulletin Cron Job Ran",
self::TYPE_CRON_EMAILER_RUN => "Emailer Cron Job Ran",
self::TYPE_CRON_SURVEY_RUN => "Survey Cron Job Ran",
self::TYPE_CRON_JOURNEY_RUN => "Journey Cron Job Ran",
self::TYPE_CRON_DOCUMENT_RUN => "Document Cron Job Ran"
),
// Global Administration
array(self::CAT_GLOBAL_ADMIN => "Global Administration") => array(
self::TYPE_GLOBAL_MAINTENANCE => "Global Maintenance",
self::TYPE_GLOBAL_EMAIL_SENDING => "Email Sending"
),
// Email Administration
array(self::CAT_EMAIL_ADMIN => "Email Administration") => array(
self::TYPE_EMAIL_SENT => "Email Sent",
self::TYPE_EMAIL_RESENT => "Email Resent",
self::TYPE_EMAIL_REMOVED => "Email Removed"
),
// DCVs Administration
array(self::CAT_DCVS_ADMIN => "DCVs Administration") => array(
self::TYPE_DCVS_FLEX_UPDATED => "Flexible Variables Updated",
self::TYPE_DCVS_GLOBAL_UPDATED => "Global Variables Updated"
),
// Video Administration
array(self::CAT_VIDEO_ADMIN => "Video Administration") => array(
self::TYPE_VIDEO_ADDED => "Video Added",
self::TYPE_VIDEO_EDITED => "Video Edited",
self::TYPE_VIDEO_REMOVED => "Video Removed"
),
// Bulletin Board Administration
array(self::CAT_BULLETIN_BOARD => "Bulletin Board Administration") => array(
self::TYPE_BULLETIN_DELETED => "Message Deleted",
self::TYPE_BULLETIN_EDITED => "Message Edited",
self::TYPE_BULLETIN_ADDED => "Message Added"
),
// User Administration
array(self::CAT_USER_ADMIN => "User Administration") => array(
self::TYPE_USER_ADDED => "User Added",
self::TYPE_USER_ADDED_MULTI => "Multiple Users Added",
self::TYPE_USER_REMOVED => "User Removed",
self::TYPE_USER_REMOVED_MULTI => "Multiple Users Removed",
self::TYPE_USER_UPDATED => "User Updated"
),
// Survey Administration
array(self::CAT_SURVEY_ADMIN => "Survey Administration") => array(
self::TYPE_SURVEY_ADDED => "Survey Added",
self::TYPE_SURVEY_UPDATED => "Survey Updated",
self::TYPE_SURVEY_REMOVED => "Survey Removed",
self::TYPE_SURVEY_REMOVED_MULTI => "Multiple Surveys Removed"
)
);
它是一種惱人再拍陣只是爲了界定什麼是這裏的鍵被定義,所以我想知道,如果這是我的問題。如果是這樣,我想我將不得不爲類別ID和字符串值做一個鍵值數組。
謝謝!
請問爲什麼?在你的例子中,每個元素的鍵總是不同的。因此,不要使用'array(self :: CAT_USER_ADMIN =>'User Admin')',爲什麼不使用'self :: CAT_USER_ADMIN'? – ircmaxell 2010-08-17 16:40:10