public static function combine(array $array, callable $callback, bool $overwrite = true): array
    {
        $combined = [];

        foreach ($array as $key => $value) {
            $combinator = $callback($value, $key);

            // fix for hhvm #1871 bug
            if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.10.0', '<=')) {
                $combinator->next();
            }

            $index = $combinator->key();

            if ($overwrite || ! isset($combined[$index])) {
                $combined[$index] = $combinator->current();
            }
        }

        return $combined;
    }
public static function combine(array $array, callable $callback, bool $overwrite = true): array
    {
        $combined = [];

        foreach ($array as $key => $value) {
            $combinator = $callback($value, $key);

            // fix for hhvm #1871 bug
            if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.10.0', '<=')) {
                $combinator->next();
            }

            $index = $combinator->key();

            if ($overwrite || ! isset($combined[$index])) {
                $combined[$index] = $combinator->current();
            }
        }

        return $combined;
    }
public static function combine ( array $ array , callable $ callback , bool $ overwrite = true ) : array { $ combined = [ ] ; foreach ( $ array as $ key => $ value ) { $ combinator = $ callback ( $ value , $ key ) ; // fix for hhvm #1871 bug if ( defined ( 'HHVM_VERSION' ) && version_compare ( HHVM_VERSION , '3.10.0' , '<=' ) ) { $ combinator -> next ( ) ; } $ index = $ combinator -> key ( ) ; if ( $ overwrite || ! isset ( $ combined [ $ index ] ) ) { $ combined [ $ index ] = $ combinator -> current ( ) ; } } return $ combined ; }
Indexes an array depending on the values it contains.

@param array    $array
@param callable $callback  Function to combine values.
@param bool     $overwrite Should duplicate keys be overwritten?

@return array Indexed values.
Indexes an array depending on the values it contains .