密钥PHP的多个值

时间:2013-08-30 13:49:40

标签: php content-management-system

PHP的新手,如果我不知道命名法,请原谅我。下面我设置键以与CMS中的字段对应,以及基于这些键提取结果的条件。

if (!empty($query->where[1])) {
    foreach ($query->where[1]['conditions'] as $key => $value) {
      if (strstr($query->where[1]['conditions'][$key]['field'], 'field_data_field_program_type.field_program_type_value')) {
        $query->where[1]['conditions'][$key]['field'] = '(field_data_field_program_type.field_program_type_value = :program_type_value AND field_data_field_project_type.field_project_type_value = :activity_project_type)'
            . ' OR field_data_field_project_type.field_project_type_value = :tl_project_type';
        $query->where[1]['conditions'][$key]['value'] = array(
          ':program_type_value' => 'Calendar',
          ':activity_project_type' => ACTIVITY_PROJECT_TYPE,
          ':tl_project_type' => TL_PROJECT_TYPE,
        );

但是,现在我需要一个额外的值(我们称之为'Test')分配给'program_type_value'键,因为我需要提取包含'Calendar'和'Test'的结果。我尝试过一些东西,却无法发挥作用。

1 个答案:

答案 0 :(得分:0)

':program_type_value' => array('Calendar','Test')

或者,在PHP 5.4 +

':program_type_value' => ['Calendar','Test']