src/Arr.php
public static function valuesWithType(array $inputArray, string $type): array
    {
        $newArray = [];
        foreach ($inputArray as $key => $value) {
            if (is_scalar($value)) {
                $newValue = $value;
                settype($newValue, $type);
                $newArray[$key] = $newValue;
            }
        }

        return $newArray;
    }
public static function valuesWithType(array $inputArray, string $type): array
    {
        $newArray = [];
        foreach ($inputArray as $key => $value) {
            if (is_scalar($value)) {
                $newValue = $value;
                settype($newValue, $type);
                $newArray[$key] = $newValue;
            }
        }

        return $newArray;
    }
public static function valuesWithType ( array $ inputArray , string $ type ) : array { $ newArray = [ ] ; foreach ( $ inputArray as $ key => $ value ) { if ( is_scalar ( $ value ) ) { $ newValue = $ value ; settype ( $ newValue , $ type ) ; $ newArray [ $ key ] = $ newValue ; } } return $ newArray ; }
Get a new array with all scalar values cast to type.

@param array  $inputArray
@param string $type
@return array
Get a new array with all scalar values cast to type .