Based on http://de3.php.net/manual/en/function.implode.php#94688
/** * Casts empty values aside and works both with one- and multi-dimensional arrays * * @author Fabian Wolf * @link http://fwolf.info/ * @link http://de3.php.net/manual/en/function.implode.php#94688 */ function recombine( $glue, $pieces ) { $string = ''; if(is_array($pieces) != false){ reset($pieces); while(list($key, $value) = each($pieces)) { if( !empty($value) ) { // avoid empty values $string .= $glue . recombine($glue, $value); } } } else { return $pieces; } return trim($string, $glue); }