PHP中的数组等于/不等于

时间:2015-04-29 10:29:03

标签: php arrays wordpress conditional-statements

我在wordpress网站上工作,我遇到阵列问题。

这是代码:

'text' => array(
    'type' => 'text',
    'title' => __('Subtitle', 'wpml'),
    'description' => __('Enter subtitle text or leave empty to hide.', 'wpml'),
    'condition' => array('type', '==', 'something1')
),

如何将多个项目放入condition

我需要3项(something1,something5,something8)等于条件。

编辑: 这是后端插件的一部分,我可以选择允许输入描述的元素,哪些不是。

这是全班:

function shortcode_options_fields() {

        $this->shortcode_options = array(
                'type' => array(
                'type' => 'select',
                'title' => __('Type', 'wpml'),
                'description' => __('Select services type.', 'wpml'),
                'options' => array(
                    'service1' => __('Service 1', 'wpml'),
                    'service2' => __('Service 2', 'wpml'),
                    'service3' => __('Service 3', 'wpml'),
                    'service4' => __('Service 4', 'wpml'),
                    'service5' => __('Service 5', 'wpml'),
                    'service6' => __('Service 6', 'wpml'),
                    'service7' => __('Service 7', 'wpml'),
                    'service8' => __('Service 8', 'wpml'),
                    'service9' => __('Service 9', 'wpml'),

                ),
                'default' => 'service1'
            ),
            'text' => array(
                'type' => 'text',
                'title' => __('Title', 'wpml'),
                'description' => __('Service title.', 'wpml')
            ),
            'subtitle' => array(
                'type' => 'text',
                'title' => __('Subtitle', 'wpml'),
                'description' => __('Enter subtitle text or leave empty to hide.', 'wpml'),
                'condition' => array()
            ),
            'description' => array(
                'type' => 'textarea',
                'title' => __('Description', 'wpml'),
                'description' => __('Service description.', 'wpml'),
                'condition' => array('type', '==', 'service1')
            ),

        );
    }

只有服务1,5和8 shuld没有别的描述。

我希望这会更清楚, 感谢

1 个答案:

答案 0 :(得分:0)

您可以在Wordpres的文档中找到更多详细信息: https://codex.wordpress.org/

但我相信你正在寻找类似的东西:

'text' => array(
'type' => 'text',
'title' => __('Subtitle', 'wpml'),
'description' => __('Enter subtitle text or leave empty to hide.', 'wpml'),
'condition' => array('type', '==', ('something1', 'something2', 'something3'))
),