public static function values2csv(array $array, $separator = ',')
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $rows = [];
        $lineSeparator = "\n";

        foreach ($array as $row) {
            /*
             * I have to use html_entity_decode() function here, because some string values can contain
             * entities with semicolon and this can destroy the CSV column order.
             */

            if (is_array($row) && !empty($row)) {
                foreach ($row as $key => $value) {
                    $row[$key] = html_entity_decode($value);
                }

                $rows[] = implode($separator, $row);
            }
        }

        if (empty($rows)) {
            return '';
        }

        return implode($lineSeparator, $rows);
    }