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

  • Home
  • SEARCH
  • 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 6549101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:03:05+00:00 2026-05-25T12:03:05+00:00

I have an array from which I need to remove null values: [227] =>

  • 0

I have an array from which I need to remove null values:

 [227] => Array
    (
        [0] => 3
        [1] => 8
        [2] => 
        [3] => 
        [4] => 1
    )

)

I tried array_filter($quantity);

and also

foreach ($quantity as $key => $value) {
    if (is_null($value) || $value=="") {
        unset($quantity);
    }
}

and even tried the foreach with $quantity[0] and got Undefined offset 0. Any ideas?

UPDATE

This works but what if i dont have the 227

foreach ($quantityval[227] as $key => $value) {
   if (is_null($value) || trim($value)=="") {  
      unset($quantityval[227][$key]);
  }
 }
  • 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-05-25T12:03:06+00:00Added an answer on May 25, 2026 at 12:03 pm

    This looks like a nested array — your foreach statement looks correct, but needs to check the inner arrays:

    foreach ($quantity as $key => $item)
        foreach ($item as $key2 => $item2) {
            if (is_null($item2) || $item2=="") {
                unset($quantity[$key][$key2]);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby (1.9.2) array which I need to remove an object from.
I have text files which I need to remove stop words from them. I
I have an array of values that is passed to my function from a
I have a JavaScript array as below which I need to filter to get
OK i have two groups of mobile numbers (from mysql) which i need to
I have a flat CSV file which I need read from to end up
So I have an array of records retreived from a database. The array is
I have a byte array in memory, read from a file. I would like
I have been working with a string[] array in C# that gets returned from
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove

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.