CSV を走査する php メソッド csv を走査する php クラス
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-07-25 08:56:15
-
- /**
- * CSV ファイルをトラバースする
- * 編集: bbs.it-home.org
- */
- class CSVIterator は Iterator を実装します
- {
- const ROW_SIZE = 4096;
-
- private $filePointer;
- private $currentElement;
- private $rowCounter;
- private $ delimiter;
-
- public function __construct( $file, $delimiter = ',' )
- {
- $this->filePointer = fopen( $file, 'r' );
- $this->delimiter = $delimiter;
- }
-
- public function rewind()
- {
- $this->rowCounter = 0;
- rewind( $this->filePointer );
- }
-
- public function current()
- {
- $this->currentElement = fgetcsv( $this->filePointer, self::ROW_SIZE, $this->delimiter );
- $this->rowCounter++;
- return $this->currentElement;
- }
-
- public function key()
- {
- return $this->rowCounter;
- }
-
- public function next()
- {
- return !feof( $this->filePointer );
- }
-
- public function valid()
- {
- if( !$this ->next() )
- {
- fclose( $this->filePointer );
- return FALSE;
- }
- return TRUE;
- }
-
- } // end class
- ?>
复制代
|
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
著者別の最新記事
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11