如何从php中的特定键移位数组?

时间:2017-03-15 10:01:00

标签: php yii

我有以下数组:

your_project/your_app/migrations/

但我想将密钥号2设为空白

Array
(
    [0] => Array
        (
            [content_id] => 2489
            [author_id] => 5
            [category_name] => Customer Experience
            [vanity_url] => launching-reviews-the-decisive-marketing-software-evaluation-platform
            [title] => Launching ‘Reviews’ – the Decisive Marketing Software Evaluation Platform
            [content_image] => 55819897a71ab751db8b552d2d8a0728.jpg
            [info_type] => N
            [publish_date] => 2016-02-16 19:01:00
            [subcat_vanity_url] => customer-experience
        )

[1] => Array
    (
        [content_id] => 2407
        [author_id] => 5
        [category_name] => Sales Enablement
        [vanity_url] => 6-steps-required-to-build-an-account-based-marketing-plan
        [title] => 6 Steps Required To Build An Account Based Marketing Plan
        [content_image] => dreamforce_guest_post_1_57f220de2fa70.jpg
        [info_type] => A
        [publish_date] => 2016-02-08 18:21:00
        [subcat_vanity_url] => sales-enablement
    )

[2] => Array
    (
        [content_id] => 2450
        [author_id] => 5
        [category_name] => Content Marketing
        [vanity_url] => what-is-content-chaos-and-how-to-tackle-it
        [title] => What is Content Chaos and How To Tackle It?
        [content_image] => dreamforce_guest_post_1_57f2212e48557.jpg
        [info_type] => A
        [publish_date] => 2016-02-12 16:22:00
        [subcat_vanity_url] => content-marketing
    )

[3] => Array
    (
        [content_id] => 2711
        [author_id] => 4880
        [category_name] => Content Marketing
        [vanity_url] => this-is-test-for-single-double-quotes-title
        [title] => This is test for 'single' & "double" quote's - Title ~ ! @ # $ % ^ & * ( ) _ +
        [content_image] => handimgnew_5892fd0eb9775.jpg
        [info_type] => A
        [publish_date] => 2017-02-02 15:04:06
        [subcat_vanity_url] => content-marketing
    )
)

我该怎么做?

1 个答案:

答案 0 :(得分:-1)

如果要为特定的数组索引添加一些值或使其为空,请使用如下;

$array[$indexNo] = '';

要访问深入的值:

$array[$indexNo]['content_id'];