PHP: remove empty array strings in multidimensional array -


this question has answer here:

i have array:

$arymain = array(array('hello','bye'), array('',''),array('',''));  

it formed reading csv file , array('','') empty rows @ end of file.

how can remove them?

i've tried:

$arymain = array_filter($arymain);   

but not working :(

thanks lot!

to add rikesh's answer:

<?php $arymain = array(array('hello','bye'), array('',''),array('',''));  $arymain = array_filter(array_map('array_filter', $arymain)); print_r($arymain);  ?> 

sticking code array_filter rid of entire arrays themselves.

array (     [0] => array         (             [0] => hello             [1] => bye         )  ) 

compared to:

$arymain = array_map('array_filter', $arymain);  array (     [0] => array         (             [0] => hello             [1] => bye         )      [1] => array         (         )      [2] => array         (         )  ) 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -