Open nathggns opened 11 years ago
This should work. I'll commit this later.
<?php /** * Implode using keys as well as values */ function key_implode($pair_glue, $glue, $arr) { $key_arr = []; foreach ($arr as $key => $val) { $key_arr[] = is_int($key) ? [$val] : [$key, $val]; } $key_arr = array_map(function($val) use($pair_glue) { return implode($pair_glue, $val); }, $key_arr); return $glue ? implode($glue, $key_arr) : $key_arr; }
This should work. I'll commit this later.