|
本文实例讲述了php遍历CSV类。分享给大家供大家参考。具体如下:
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
?>
希望本文所述对大家的php程序设计有所帮助。
您可能感兴趣的文章:PHP 数据库树的遍历方法php FLEA中二叉树数组的遍历输出php对关联数组循环遍历的实现方法php遍历删除整个目录及文件的方法php递归遍历删除文件的方法php递归遍历多维数组的方法PHP遍历数组的方法汇总php遍历类中包含的所有元素的方法php遍历树的常用方法汇总
|
|