CsvFile::put: Bitrix method

      
<?php 
//  Bitrix\Translate\IO\CsvFile :: put()
//  /dist/bitrix/modules/translate/lib/io/csvfile.php:607

    
public function put(array $fields)
    {
        
$length false;
        
$throw32KWarning false;
        if (
$this->fieldsType == self::FIELDS_TYPE_WITH_DELIMITER)
        {
            
$content '';
            for (
$i 0$n count($fields); $i $n$i++)
            {
                if (
$i>0)
                {
                    
$content .= $this->fieldDelimiter;
                }
                
//$pos1 = strpos($fields[$i], $this->fieldDelimiter);
                //$pos2 = $pos1 || strpos($fields[$i], "\"");
                //$pos3 = $pos2 || strpos($fields[$i], "\n");
                //$pos4 = $pos3 || strpos($fields[$i], "\r");
                //if ($pos1 !== false || $pos2 !== false || $pos3 !== false || $pos4 !== false)
                
if (preg_match("#[\"\n\r]+#".BX_UTF_PCRE_MODIFIER$fields[$i]))
                {
                    
$fields[$i] = str_replace("\"""\"\""$fields[$i]);
                    
$fields[$i] = str_replace("\\""\\\\"$fields[$i]);
                }
                
$content .= "\"";
                
$content .= $fields[$i];
                
$content .= "\"";

                
// ms excel las limitation with total number of characters that a cell can contain 32767 characters
                
if ($throw32KWarning !== true && strlen($fields[$i]) > 32767)
                {
                    
$throw32KWarning true;
                }
            }
            if (
$content <> '')
            {
                
$content .= $this->rowDelimiter;

                
$length $this->write($content);
                if (
$length !== false)
                {
                    
$this->fileSize += $length;
                }
            }
        }
        
// todo: $this->fieldsType == self::FIELDS_TYPE_FIXED_WIDTH

        
if ($throw32KWarning)
        {
            if (!
$this->hasError(self::ERROR_32K_FIELD_LENGTH))
            {
                
$this->addError(new Main\Error(
                    
'Excel has limit when the total number of characters that a cell can contain is 32767 characters.',
                    
self::ERROR_32K_FIELD_LENGTH
                
));
            }
        }

        return (
$length !== false);
    }