core/helpers/ExportHelper.php
public static function csv($input, array $keys = [], $header = true)
    {
        $delimiter = ",";
        $input = self::transformInput($input);
        $array = self::generateContentArray($input, $keys, $header);

        return self::generateOutputString($array, $delimiter);
    }
public static function csv($input, array $keys = [], $header = true)
    {
        $delimiter = ",";
        $input = self::transformInput($input);
        $array = self::generateContentArray($input, $keys, $header);

        return self::generateOutputString($array, $delimiter);
    }
public static function csv ( $ input , array $ keys = [ ] , $ header = true ) { $ delimiter = "," ; $ input = self :: transformInput ( $ input ) ; $ array = self :: generateContentArray ( $ input , $ keys , $ header ) ; return self :: generateOutputString ( $ array , $ delimiter ) ; }
Export an Array or ActiveQuery instance into a CSV formated string.

@param array|ActiveQueryInterface $input The data to export into a csv
@param array $keys Defines which keys should be packed into the generated CSV. The defined keys does not change the sort behavior of the generated csv.
@param string $header Whether the column name should be set as header inside the csv or not.
@return string The generated CSV as string.
Export an Array or ActiveQuery instance into a CSV formated string .