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;
    }
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;
    }
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 ; }
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
Reindexes a list of values .