如何从php数组中排除值

时间:2016-01-25 21:06:25

标签: php wordpress woocommerce

我在WordPress查询选项中有以下数组用于输出产品类别,我需要按类别ID从中排除某些值,我该怎么办?

$args = apply_filters( 'storefront_product_categories_args', array(
            'limit'             => 12,
            'columns'           => 3,
            'child_categories'  => 0,
            'orderby'           => 'name',
            'order'             => 'asc',
            'title'             => __( '', 'storefront' ),

非常感谢。

1 个答案:

答案 0 :(得分:1)

通过密钥从PHP数组中删除项目是使用unset函数完成的:

$array = array(
    'limit'             => 12,
    'columns'           => 3,
    'child_categories'  => 0,
    'orderby'           => 'name',
    'order'             => 'asc',
    'title'             => 'something',
);

unset( $array[ 'columns' ] );

var_dump( $array );