时时商务社区

标题: php遍历CSV类实例 [打印本页]

作者: 网络通达    时间: 2018-2-14 05:46

            本文实例讲述了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遍历树的常用方法汇总
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2