API16

JStreamString/stream seek: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 1: Line 1:
{{subst:Description:JStreamString/stream_seek}}
===Syntax===
===Syntax===
<source lang="php">stream_seek($offset, $whence)</source>
<source lang="php">stream_seek($offset, $whence)</source>
Line 53: Line 51:




{{subst:SeeAlso:JStreamString/stream_seek}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=stream_seek
  category=stream_seek
  category=JStreamString
  category=JStreamString
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:08, 25 March 2017

Syntax

stream_seek($offset, $whence)
Parameter Name Default Value Description
$offset
$whence

Defined in

libraries/joomla/filesystem/streams/string.php

Importing

jimport( 'joomla.filesystem.streams.string' );

Source Body

function stream_seek($offset, $whence) {
        //$whence: SEEK_SET, SEEK_CUR, SEEK_END
        if($offset > $this->_len) {
                return false; // we can't seek beyond our len
        }
        switch($whence)
        {
                case SEEK_SET:
                        $this->_pos = $offset;
                        break;
                case SEEK_CUR:
                        if (($this->_pos + $offset) < $this->_len) {
                                $this->_pos += $offset;
                        }
                        else {
                                return false;
                        }
                        break;
                case SEEK_END:
                        $this->_pos = $this->_len - $offset;
                        break;
        }
        return true;
}



Examples

Code Examples