PHP code example of iqb / substream

1. Go to this page and download the library: Download iqb/substream library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iqb / substream example snippets


composer 


use const iqb\stream\SUBSTREAM_SCHEME;

$originalStream = fopen('filename', 'r');
$offset = 25;
$length = 100;

// Provide the stream via a stream context
$context = stream_context_create([SUBSTREAM_SCHEME => ['stream' => $originalStream]]);
$substream = fopen(SUBSTREAM_SCHEME . "://$offset:$length", "r", false, $context);

// Alternatively, you can just put the stream into the URL
$substream = fopen(SUBSTREAM_SCHEME . "://$offset:$length/$originalStream", "r");

fseek($orignalStream, 50);
fseek($substream, 25);

// Will not fail
assert(fread($originalStream, 50) === fread($substream, 50));