我有一个dropdown list函数,它向我显示了从两个不同的results过滤queries的名称。一个带有numeric中的value 1-4,另一个带有10-110,某些结果具有相同的strings

function filter_workhires($status) {
    $status = array();
    $status[1] = 'booked';
    $status[70] = 'booked';
    $status[2] = 'partiallyattended';
    $status[90] = 'partiallyattended';
    $status[3] = 'fullyattended';
    $status[100] = 'fullyattended';
    $status[4] = 'notattended';
    $status[80] = 'notattended';
    $status[10] = 'status_user_cancelled';
    $status[20] = 'status_session_cancelled';
    $status[30] = 'status_declined';
    $status[40] = 'status_requested';
    $status[50] = 'status_approved';
    $status[60] = 'status_waitlisted';
    $status[110] = 'status_not_set';

    return $status;
}


通过这种形式,我得到了double names作为示例booked。如何根据显示的字符串combine statuses

最佳答案

return array_unique($status);


就是这样:)

输出量

Array
(
    [1] => booked
    [2] => partiallyattended
    [3] => fullyattended
    [4] => notattended
    [10] => status_user_cancelled
    [20] => status_session_cancelled
    [30] => status_declined
    [40] => status_requested
    [50] => status_approved
    [60] => status_waitlisted
    [110] => status_not_set
)

09-19 19:15