downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SplFileObject::setFlags> <SplFileObject::seek
[edit] Last updated: Fri, 25 May 2012

view this page in

SplFileObject::setCsvControl

(PHP 5 >= 5.2.0)

SplFileObject::setCsvControlCSV の区切り文字と囲み文字をセットする

説明

public void SplFileObject::setCsvControl ([ string $delimiter = "," [, string $enclosure = "\"" [, string $escape = "\\" ]]] )

CSV フィールド処理用の区切り文字と囲み文字をセットします。

パラメータ

delimiter

フィールドの区切り文字 (1 文字のみ)。

enclosure

フィールドの囲み文字 (1 文字のみ)。

escape

フィールドのエスケープ文字 (1 文字のみ)。

返り値

値を返しません。

例1 SplFileObject::setCsvControl() の例

<?php
$file 
= new SplFileObject("data.csv");
$file->setFlags(SplFileObject::READ_CSV);
$file->setCsvControl('|');
foreach (
$file as $row) {
    list (
$fruit$quantity) = $row;
    
// Do something with values
}
?>

data.csv の内容

<?php
apples|20
bananas|14
cherries|87
?>

参考



add a note add a note User Contributed Notes SplFileObject::setCsvControl
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites