找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 899|回复: 0
打印 上一主题 下一主题

php遍历CSV类实例

[复制链接]

2647

主题

2647

帖子

7881

积分

论坛元老

Rank: 8Rank: 8

积分
7881
跳转到指定楼层
楼主
发表于 2018-2-14 05:46:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            本文实例讲述了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遍历树的常用方法汇总
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端