Reindexes a list of values.

@param array $array
@param array $map      An map of correspondances of the form
['currentIndex' => 'newIndex'].
@param bool  $unmapped Whether or not to keep keys that are not
remapped.

@return array
329473
public static function reindex(array $array, array $map, bool $unmapped = true): array
    {
        $reindexed = $unmapped
            ? $array
            : [];

        foreach ($map as $from => $to) {
            if (isset($array[$from])) {
                $reindexed[$to] = $array[$from];
            }
        }

        return $reindexed;
    }
1328963
public function set($map)
    {
        \UArray::convertToArray($map);
        $result = [];
        foreach ($map as $key => $item) {
            $validation = $this->formatItemSeed($item, $key);
            if ($validation) {
                $result[$key] = $item;
            }
        }
        $this->seed = json_encode($result);
        $this->map = $map;
        return $this;
    }
678415
public static function reset(array $array, $deep = false)
    {
        $target = [];

        foreach ($array as $key => $value) {
            if ($deep && is_array($value)) {
                $value = static::reset($value);
            }

            if (is_numeric($key)) {
                $target[] = $value;
            } else {
                $target[$key] = $value;
            }
        }

        return $target;
    }
150677
public function createMapping(array $map)
    {
        try {
            $elasticclient = $this->client->getClient();
            $response = $elasticclient->indices()->create($map);
            return  $response['acknowledged'];
        } catch (\Exception $ex) {
            return $ex->getMessage();
        }
    }
660551
private function narrowArray(array $array, string $key = null)
    {
        if ($key) {
            $key .= '--';
        }

        $result = [];

        foreach ($array as $index => $value) {
            if (is_array($value)) {
                $result = array_merge($result, $this->narrowArray($value, $key . $index));
            } else {
                $result[$key . $index] = $value;
            }
        }

        return $result;
    }
244858
public static function serializedObjectToArray(array &$array, array &$mappings)
    {
        foreach ($array as $key => &$value) {
            if ($key === Serializer::CLASS_IDENTIFIER_KEY) {
                $type = $array[Serializer::CLASS_IDENTIFIER_KEY];
                if (empty($mappings[$type])) {
                    unset($array[Serializer::CLASS_IDENTIFIER_KEY]);
                }
            }
            if (is_array($value)) {
                foreach($value as $k => &$v) {
                    if (is_array($v)) {
                        $v = self::serializedObjectToArray($v, $mappings);
                    }
                }
            }
        }
        return $array;
    }
1008620
protected function _createInsertAndReplaceValues($array) {
		$keys = [];
		$values = [];
		$binds = [];
		
		foreach ($array as $value) {
			if (is_array($value)) {
				$values[] = $value['FUNC'];
			} else {
				$values[] = '?';
				$binds[] = $value;
			}
		}

		$keys = implode(',', array_keys($array));
		$values = implode(',', $values);
		
		$returner = compact('keys', 'values', 'binds');
		return $returner;
	}
1329778
public static function map(array $array, callable $callback, $recursive = false)
    {
        $results = [];

        foreach ($array as $key => &$value) {
            if ($recursive && is_array($value)) {
                $results[$key] = static::map($value, $callback, $recursive);
            } else {
                $results[$key] = $callback($value, $key);
            }
        }

        return $results;
    }
1057578
private function getArrayValues($array)
    {
        $out = [];
        $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));

        foreach ($it as $value) {
            $out[] = $value;
        }
        return $out;
    }
88163
public function renameMany(array $map) : Assoc
    {
        $pairs = array_map(function ($a, $b) {
            return [$a, $b];
        }, array_keys($map), array_values($map));

        return array_reduce($pairs, function ($that, $pair) {
            list ($from, $to) = $pair;

            return $that->rename($from, $to);
        }, $this);
    }
1114259
protected function getMappedKey($map, $key)
    {
        if (is_array($map)) {
            if (array_key_exists($key, $map)) {
                return $map[$key];
            } else {
                return $key;
            }
        }
        return $key;
    }
700367
public function unshift(array $array, $element): array
    {
        // get all elements that are supposed to be added
        $elements = func_get_args();
        array_shift($elements);
        foreach ($elements as $element) {
            array_unshift($array, $element);
        }
        return $array;
    }
146354
public function array_map( $array, $callback ) {
		$array = $this->get_array_value( $array );

		return array_map( function ( $d ) use ( $callback ) {
			return is_callable( $callback ) ? $callback( $d ) : ( is_string( $callback ) && method_exists( $d, $callback ) ? $d->$callback() : null );
		}, $array );
	}
222221
protected function buildJsonAttributes(array $map): array
    {
        $result = [];

        foreach ($map as $jsonKey => $value) {
            if ($value !== null) {
                $result[$jsonKey] = $value;
            }
        }

        return $result;
    }
1078606
public static function prepend($array, $value, $key = null)
    {
        if (is_null($key)) {
            array_unshift($array, $value);
        } else {
            $array = [$key => $value] + $array;
        }

        return $array;
    }
804856
protected function setValueMap(array $map)
    {
        $lower = array_change_key_case($map);
        $this->caseSensitive = count($lower) !== count($map);
        $this->valueMap = $this->caseSensitive ? $map : $lower;
    }
1265958
private function recurArrayChange($array, $keyArray, $value = null)
    {
        $key0 = $keyArray[0];
        if (count($keyArray) === 1) {
            $this->changeValue($array, $key0, $value);
        } else if (is_array($array) && isset($keyArray[1])) {
            unset($keyArray[0]);
            $keyArray = array_values($keyArray);
            if (!isset($array[$key0])) {
                $array[$key0] = [];
            }
            $array[$key0] = $this->recurArrayChange($array[$key0], $keyArray, $value);
        } else {
            $this->changeValue($array, $key0, $value);
        }
        return $array;
    }