rewind

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Rewind the position of a file pointer
<?php rewind(resource $stream): bool
<?php     public function truncate()

    {

        rewind($this->handle);



        ftruncate($this->handle, 0);
<?php             }



            fwrite($sink, $body);

            rewind($sink);

        };

    }
<?php         $string = 'Look at me, i am a stream!!';

        $resource = fopen('php://temp', 'w');

        fwrite($resource, $string);

        rewind($resource);

        $body = Utils::streamFor($resource);



        $fakeRequest = function (Request $request) use ($string) {
<?php             new StreamedResponse(function () {

                $stream = fopen('php://memory', 'r+');

                fwrite($stream, 'expected response data');

                rewind($stream);

                fpassthru($stream);

            })

        );
<?php {

    $stream = fopen('php://temp', 'w+b');

    fwrite($stream, $contents);

    rewind($stream);



    return $stream;

}
<?php     private function rewindStream($resource): void

    {

        if (ftell($resource) !== 0 && stream_get_meta_data($resource)['seekable']) {

            rewind($resource);

        }

    }

}
<?php         try {

            $writeStream = fopen('php://temp', 'w+b');

            fwrite($writeStream, $contents);

            rewind($writeStream);

            $this->writeStream($path, $writeStream, $config);

        } finally {

            isset($writeStream) && is_resource($writeStream) && fclose($writeStream);
<?php             throw UnableToReadFile::fromLocation($path);

        }



        rewind($stream);



        return $stream;

    }
<?php         $stream = fopen('php://temp', 'w+b');

        fwrite($stream, $this->contents);

        rewind($stream);



        return $stream;

    }
<?php             throw UnableToReadFile::fromLocation($path);

        }



        rewind($readStream);



        return $readStream;

    }
<?php             throw UnableToReadFile::fromLocation($path);

        }



        rewind($readStream);



        return $readStream;

    }
<?php         $response->setCallback(function () use ($stream) {

            if (ftell($stream) !== 0) {

                rewind($stream);

            }

            fpassthru($stream);

            fclose($stream);
<?php             fwrite($stream, $input.PHP_EOL);

        }



        rewind($stream);



        return $stream;

    }
<?php                     throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);

                }

                $statusCode = $progress['http_code'];

                rewind($job['headerHandle']);

                $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));

                fclose($job['headerHandle']);
<?php                 if ($job['filename']) {

                    $contents = $job['filename'].'~';

                    if ($statusCode >= 300) {

                        rewind($job['bodyHandle']);

                        $contents = stream_get_contents($job['bodyHandle']);

                    }

                    $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);