当前位置: 首页>>代码示例>>PHP>>正文


PHP Reader::rewind方法代码示例

本文整理汇总了PHP中Reader::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::rewind方法的具体用法?PHP Reader::rewind怎么用?PHP Reader::rewind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reader的用法示例。


在下文中一共展示了Reader::rewind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rewind

 function rewind()
 {
     parent::rewind();
     rewind($this->_file_handler);
     if (($this->_header = fgetcsv($this->_file_handler, 0, $this->_delimiter)) == false) {
         throw new \Exception("Reading of Header was failed");
     }
 }
开发者ID:litmanovitziv,项目名称:struct-reader,代码行数:8,代码来源:CSVReader.php

示例2: testReader

    public function testReader()
    {
        $text = <<<HTML
HELLO WORLD
HTML;
        $reader = new Reader($text);
        $this->assertEquals(strlen($text), strlen(trim($text)));
        $this->assertEquals("HE", $reader->read(2));
        $this->assertEquals(strlen($text), $reader->length());
        $this->assertEquals(6, $reader->moveCursor(6)->getCursor());
        $this->assertEquals('WORLD', $reader->readToEnd());
        $this->assertEquals('HELLO WORLD', $reader->rewind()->readToEnd());
        $this->assertEquals('HELLO ', $reader->readAndGo(6));
        $this->assertEquals('WORLD', $reader->readToEnd());
        # Reset position
        $reader->rewind();
        $this->assertNotFalse($reader->match('/(?=[a-z])/iA'));
        $this->assertEquals('HELLO', $reader->match('/\\w+/A'));
        $this->assertEquals(0, $reader->getCursor());
        $this->assertFalse($reader->matchAndGo('/\\d+/A'));
        $this->assertEquals('HELLO', $reader->matchAndGo('/\\w+/A'));
        $this->assertEquals(' ', $reader->matchAndGo('/\\s+/A'));
        $this->assertEquals('WORLD', $reader->matchAndGo('/\\w+/A'));
        $this->assertTrue($reader->isEnd());
        $reader->rewind();
        $this->assertEquals('HELLO WORLD', $reader->readToEndAndGo());
        $this->assertEquals(11, $reader->length());
        $this->assertEquals(10, $reader->getCursor());
        $this->assertTrue($reader->isEnd());
        $reader = new Reader('
		Hello
		World
		');
        $reader->setCursor(strpos($reader->readAll(), 'World'));
        $this->assertEquals(3, $reader->getLine());
        $this->assertEquals(2, $reader->getColumn());
    }
开发者ID:mdzzohrabi,项目名称:azera-fry,代码行数:37,代码来源:ReaderTest.php

示例3: rewind

 function rewind()
 {
     parent::rewind();
     rewind($this->_file_handler);
 }
开发者ID:litmanovitziv,项目名称:struct-reader,代码行数:5,代码来源:JSONReader.php

示例4: initialize

 /**
  * Realiza la revision del archivo
  *
  * @param string $fileName
  */
 protected function initialize(Reader $reader)
 {
     $this->checkCsvFile($reader->getFilename());
     if (count($this->rules) === 0) {
         throw new Exception(' No se puede revistar el documento sin antes haber definido reglas @ ' . __LINE__);
     }
     $index = $reader->getHeaders();
     if (count($this->index) > 0) {
         $faltan = array_diff($this->index, $index);
         if (count($faltan)) {
             $this->addError('Se detectaron columnas faltantes en el archivo, se necesitan ' . implode(', ', $this->index) . ' y se encontraron ' . implode(', ', $index) . ' Faltando ' . implode(', ', $faltan) . '');
         }
     }
     $reader->rewind();
     while ($reader->valid()) {
         $this->applyRules($reader->current(), $reader->getLineNumber());
         $reader->next();
     }
 }
开发者ID:Eximagen,项目名称:sochi,代码行数:24,代码来源:Checker.php


注:本文中的Reader::rewind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。