重複の可能性:
PHP(> = 5.0)では、参照による受け渡しが高速ですか?
参照によってパラメーターの受け渡しを宣言することにより、文字列を関数のローカルスコープにコピーする必要がないため、PHPインタープリターが高速になるのではないでしょうか。このスクリプトは、XMLファイルを何千ものレコードを持つCSVに変換するため、時間の最適化はほとんど重要ではありません。
これでしょうか:
function escapeCSV( & $string )
{
$string = str_replace( '"', '""', $string ); // escape every " with ""
if( strpos( $string, ',' ) !== false )
$string = '"'.$string.'"'; // if a field has a comma, enclose it with dobule quotes
return $string;
}
これより速くする:
function escapeCSV( $string )
{
$string = str_replace( '"', '""', $string ); // escape every " with ""
if( strpos( $string, ',' ) !== false )
$string = '"'.$string.'"'; // if a field has a comma, enclose it with dobule quotes
return $string;
}
?