$stream
$stream : resource
Stream resource.
Object that adds convenience/utility methods to interacting with PHP streams.
length(boolean $utf8 = false) : integer
Returns the length of the data. Does not change the stream position.
boolean | $utf8 | If true, determines the UTF-8 length of the stream (as of 1.4.0). If false, determines the byte length of the stream. |
Stream size.
getToChar(string $end, boolean $all = true) : string
Get a string up to a certain character (or EOF).
string | $end | The character to stop reading at. As of 1.4.0, $char can be a multi-character UTF-8 string. |
boolean | $all | If true, strips all repetitions of $end from the end. If false, stops at the first instance of $end. (@since 1.5.0) |
The string up to $end (stream is positioned after the end character(s), all of which are stripped from the return data).
search(string $char, boolean $reverse = false, boolean $reset = true) : mixed
Search for character(s) and return its position.
string | $char | The character to search for. As of 1.4.0, $char can be a multi-character UTF-8 string. |
boolean | $reverse | Do a reverse search? |
boolean | $reset | Reset the pointer to the original position? |
The start position of the search string (integer), or null if character not found.
getString(integer $start = null, integer $end = null) : string
Returns the stream (or a portion of it) as a string. Position values are the byte position in the stream.
integer | $start | The starting position. If positive, start from this position. If negative, starts this length back from the current position. If null, starts from the current position. |
integer | $end | The ending position relative to the beginning of the stream (if positive). If negative, end this length back from the end of the stream. If null, reads to the end of the stream. |
A string.
substring(integer $start, integer $length = null, boolean $char = false) : string
Return part of the stream as a string.
integer | $start | Start, as an offset from the current postion. |
integer | $length | Length of string to return. If null, returns rest of the stream. If negative, this many characters will be omitted from the end of the stream. |
boolean | $char | If true, $start/$length is the length in characters. If false, $start/$length is the length in bytes. |
The substring.
seek(integer $offset, boolean $curr = true, boolean $char = false) : boolean
Move internal pointer.
integer | $offset | The offset. |
boolean | $curr | If true, offset is from current position. If false, offset is from beginning of stream. |
boolean | $char | If true, $offset is the length in characters. If false, $offset is the length in bytes. |
True if successful.