Expand a flattened array with dots to a multi-dimensional associative array.

@param array  $array
@param string $prepend

@return array
439607
public static function expand(array $array, string $prepend = ''): array
    {
        $results = [];

        if ($prepend) {
            $prepend .= '.';
        }

        foreach ($array as $key => $value) {
            if ($prepend) {
                $pos = strpos($key, $prepend);

                if ($pos === 0) {
                    $key = substr($key, strlen($prepend));
                }
            }

            $results = static::set($results, $key, $value);
        }

        return $results;
    }
834641
public static function flatten($array)
    {
        $isAssoc = self::isAssoc($array);

        $flat = [];
        foreach ($array as $key => $value)
        {
            if (is_array($value))
            {
                $flat = array_merge($flat, self::flatten($value));
            }
            else
            {
                if ($isAssoc)
                {
                    $flat[$key] = $value;
                }
                else
                {
                    $flat[] = $value;
                }
            }
        }

        return $flat;
    }
528103
public static function flatten(array $array, $parent_prefix = '')
    {
        $flattened = [];

        foreach ($array as $key => $value) {
            $key = $parent_prefix . $key;
            if (is_array($value) && self::isAssoc($value)) {
                $flattened = array_merge(self::flatten($value, $key . '.'), $flattened);
            } else {
                $flattened[$key] = $value;
            }
        }

        return $flattened;
    }
1322284
protected function flattenArray($array, $prefix = '')
    {
        if (is_array($array)) {
            foreach ($array as $key => $subarray) {
                if (count($array) == 1) {
                    return $this->flattenArray($subarray, ($prefix == '' ? $prefix : $prefix.'.').$key);
                }

                $array[$key] = $this->flattenArray($subarray);
            }
        }

        if ($prefix == '') {
            return $array;
        }

        return array($prefix => $array);
    }
1059742
public function toMappedArray(array $array)
    {
        $mappedArray = [];
        foreach ($this->getMapper() as $from => $to) {
            $mappedArray[$to] = $array[$from];
        }
        return $mappedArray;
    }
959471
public static function dot(array $array, string $prepend = ''): array
    {
        $cache = serialize(['array' => $array, 'prepend' => $prepend]);

        if (array_key_exists($cache, self::$dotted)) {
            return self::$dotted[$cache];
        }

        $results = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $results = array_merge($results, static::dot($value, $prepend . $key . '.'));
            } else {
                $results[$prepend . $key] = $value;
            }
        }

        return self::$dotted[$cache] = $results;
    }
5970
protected function prepend(array $item)
    {
        if (! $this->isEnabled()) {
            $this->enable();
        }

        $container  = $this->getContainer();
        $currentArr = $container->getArrayCopy();

        array_unshift($currentArr, $item);
        $container->exchangeArray($currentArr);
    }
73328
private function yamlizeArray($array, $indent)
    {
        if (is_array($array)) {
            $string = '';
            $previous_key = -1;

            foreach ($array as $key => $value) {
                if (!isset($first_key)) {
                    $first_key = $key;
                }

                $string .= $this->yamlize($key, $value, $indent, $previous_key, $first_key, $array);
                $previous_key = $key;
            }

            return $string;
        } else {
            return false;
        }
    }
98503
public static function concat(array $array, $separator = ' ')
    {
        $result = '';

        foreach ($array as $string) {
            if (is_string($string)) {
                $result .= $string;
            }
        }

        return $result;
    }
159926
public static function prependLines( $lines, $prepend, $prependFirstLine = false )
	{
		$new = [];
		$lines = str_contains( $lines, '\r\n' ) ? explode( "\r\n", $lines ) : explode( "\n", $lines );

		if ( !$prependFirstLine )
			$new[] = $lines[0];

		for ( $i = $prependFirstLine ? 0 : 1; $i < count( $lines ); $i++ )
			$new[] = $prepend . $lines[$i];

		return implode( "\n", $new );
	}
596005
public static function flatten(array $array)
    {
        $result = array();

        array_walk_recursive($array, function ($value, $key) use (& $result) {
            if (is_numeric($key) or is_object($value)) {
                $result[] = $value;
            } else {
                $result[$key] = $value;
            }
        });

        return $result;
    }
739435
public static function formatResponseArray(array $array): array
    {
        $formattedArray = [];

        foreach ($array as $item) {
            reset($item);
            $formattedArray[key($item)] = current($item);
        }

        return $formattedArray;
    }
1235366
public static function flatten($array)
    {
        if (!is_array($array)) {
            // nothing to do if it's not an array
            return array($array);
        }

        $result = array();
        foreach ($array as $value) {
            // explode the sub-array, and add the parts
            $result = array_merge($result, static::flatten($value));
        }

        return $result;
    }
39886
public final static function prepend(string $source, array $Prepend): string {
		return self::encode(Arr::prepend(self::decode($source), $Prepend));
	}
922506
private function _yamlizeArray($array,$indent)
  {
    if (is_array($array)) {
      $string = '';
      $previous_key = -1;
      foreach ($array as $key => $value) {
        if (!isset($first_key)) $first_key = $key;
        $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array);
        $previous_key = $key;
      }

      return $string;
    } else {
      return false;
    }
  }
971829
public function flatten(array $array)
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (in_array($key, $this->exceptions)) {
                $return[$key] = $value;
            } else {
                $return[] = $value;
            }
        }

        return $return;
    }
1139047
public function build(array $prepends = []): array
    {
        if (empty($this->message)) {
            throw new RuntimeException('No message content to send.');
        }

        $content = $this->message->transformForJsonRequest();

        if (empty($prepends)) {
            $prepends = $this->to;
        }

        $message = array_merge($prepends, $content, $this->attributes);

        return $message;
    }