array_fileter() seems to be acceptable here and probably remains tbh's most reliable answer.
However, the following will also be done if you can guarantee that the glue symbol does not already exist in the lines of each element of the array (which would be set in most practical cases), otherwise you would not be able to distinguish glue from the actual data in the array):
$array = array('one', '', '', 'four', '', 'six'); $str = implode('-', $array); $str = preg_replace ('/(-)+/', '\1', $str);
cartbeforehorse Nov 04 '17 at 13:05 2017-11-04 13:05
source share