public static function flattenMultidimensionalArray(array $array, $glue) {
    $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));
    $result = array();
    foreach ($iterator as $leafValue) {
      $keys = array();
      foreach (range(0, $iterator->getDepth()) as $depth) {
        $keys[] = $iterator->getSubIterator($depth)->key();
      }
      $result[implode($glue, $keys)] = $leafValue;
    }

    return $result;
  }