Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8871807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:04:56+00:00 2026-06-14T18:04:56+00:00

How do a delete all array entries where status equals 0? That means: $array[1][3];

  • 0

How do a delete all array entries where status equals 0?

That means: $array[1][3]; and $array[4];

Array
(
    [1] => Array
        (
            [id] => 1
            [parent_id] => 0
            [status] => 2
            [title] => bananer
            [breadcrumb] => /bananer
            [slug] => /bananer
            [2] => Array
                (
                    [id] => 2
                    [parent_id] => 1
                    [status] => 2
                    [title] => sub bananer
                    [breadcrumb] => /bananer/sub bananer
                    [slug] => /bananer/sub-bananer
                )
            [3] => Array
                (
                    [id] => 3
                    [parent_id] => 1
                    [status] => 0
                    [title] => sub bananer 2
                    [breadcrumb] => /bananer/sub bananer 2
                    [slug] => /bananer/sub-bananer-2
                )
        )
    [4] => Array
        (
            [id] => 4
            [parent_id] => 0
            [status] => 0
            [title] => appelsin
            [breadcrumb] => /appelsin
            [slug] => /appelsin
            [5] => Array
                (
                    [id] => 5
                    [parent_id] => 4
                    [status] => 2
                    [title] => sub appelsin
                    [breadcrumb] => /appelsin/sub appelsin
                    [slug] => /appelsin/sub-appelsin
                )
            [6] => Array
                (
                    [id] => 6
                    [parent_id] => 4
                    [status] => 2
                    [title] => sub appelsin 2
                    [breadcrumb] => /appelsin/sub appelsin 2
                    [slug] => /appelsin/sub-appelsin-2
                )
        )
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:04:57+00:00Added an answer on June 14, 2026 at 6:04 pm

    Try this:

    function deleteIt(&$array)
    {
        foreach($array as $key => &$value)
        {
            if (is_numeric($key)) deleteIt($value);
            if (isset($value['status']) && !$value['status']) unset($array[$key]);
        }
    }
    

    This runs through the array recursively while handing references down so that the original array is modified while deleting. Notice the & in the deleteIt function prototype and in the foreach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that when delete [] will cause destruction for all array elements and
I would like to delete all elements from an array that don't meet some
For example, let's say I want to delete from the array all continuous segments
I need to delete all the folders in current directory that starts with say
Is it possible to delete all databases that were created by a specific user?
I have a table groupdentlink where I want to delete all the rows that
What does session_destroy() function do? To delete all session variables in global array $_SESSION
I have got an array with several twitter tweets and want to delete all
It is possible to delete all characters of a string that is immediately followed
How can I delete all the elements from an array, except for one in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.