0

I want to remove null rows from assoctivate array, i.e. whose values are empty

Already Check

 array[0]
      a =>  '101'
      b =>  '105'
      c =>  '103'

 array[1]
      a =>  ''
      b =>  ''
      c =>  ''

 array[2]
      a =>  '101'
      b =>  '105'
      c =>  '103'

 Desired result :- 

  array[0]
      a =>  '101'
      b =>  '105'
      c =>  '103'  

 array[1]
      a =>  '101'
      b =>  '105'
      c =>  '103'

Note :- This is a Subarray of array.i.e. Multidimensional array.

0

2 Answers 2

1

You can filter using implode.

$non_empty_rows = array_filter($array, 'implode');

That will collapse multiple null values or empty strings in each sub-array into a single empty string which will evaluate as false.

Runnable example at 3v4l.org

Sign up to request clarification or add additional context in comments.

Comments

0

As went through many post, I found simplest answer

//foreach

if (strlen(implode('', array_values($array_row))) > 0) {


}

This will not let empty row

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.