Link to home
Create AccountLog in
Avatar of Marthaj
MarthajFlag for United States of America

asked on

Filtering a multi-dimensional Array in PHP

I have a multi-dimensional array that always contains one completely blank row.
How do I remove this one blank row?  The individual elements may or may not be blank.
If they all are blank (or null ?) then I want to get rid of that row.
 I have used array_filter on a one dimensional array,
but never for a  multi-dimensional array. I am not sure why I have a blank row, I check where and when I increment my index, and I think I am good.
Below are the two errors I receive
Notice: Uninitialized string offset

 Illegal string offset :

Open in new window

And this is the structure of my array:
$_SESSION['GlobalRegionIndex'] = 0;

$_SESSION['GlobalRegionArray'] = array();
$_SESSION['GlobalRegionArray'] = array(
                   'strRegionFile' => '',
         'strRegionFileName' => '',
         'strRegionProdLocation' => '',
         'strRegionAwsLocation' => '',
         'strRegionSupplierCode' => '',
         'strRegionConfNbr' => '',
         'strRegionStatus' =>'');

Open in new window

Any help/explanation is appreciated. Thank you in advance.
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

We'll need to see your data to give you proper advice, but array_filter can be used to filter multi-dimension arrays. You say your have a completely empty row, but arrays don't contain rows, so not sure what you're referring to.
ASKER CERTIFIED SOLUTION
Avatar of Marthaj
Marthaj
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer