src/Util/Arr.php
public static function withKeys($records, $keys)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                if (!in_array($k, $keys)) {
                    continue;
                }
                $out[$n][$k] = $v;
            }
        }
        return $out;
    }
public static function withKeys($records, $keys)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                if (!in_array($k, $keys)) {
                    continue;
                }
                $out[$n][$k] = $v;
            }
        }
        return $out;
    }
public static function withKeys ( $ records , $ keys ) { if ( ! self :: iterable ( $ records ) ) { return array ( ) ; } $ out = array ( ) ; foreach ( $ records as $ n => $ record ) { if ( ! self :: iterable ( $ record ) ) { $ out [ $ n ] = $ record ; continue ; } $ out [ $ n ] = array ( ) ; foreach ( $ record as $ k => $ v ) { if ( ! in_array ( $ k , $ keys ) ) { continue ; } $ out [ $ n ] [ $ k ] = $ v ; } } return $ out ; }
Get the data only with specific keys
@param array $records
@param array $keys
@return array
Get the data only with specific keys