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
Post a Comment