ierusalim/file-records

Simple engine for Read, Append, reWrite fixed-size records in the file

0.2.0 2019-05-27 10:01 UTC

This package is auto-updated.

Last update: 2025-03-13 03:58:51 UTC


README

Build Status

Functions:

  • ->new FileRecords($file_name, $record_size)
  • ->appendRecord($data)
  • ->readRecord($record_number)
  • ->reWriteRecord($record_number, $new_data)

Example:

<?php
    namespace ierusalim\FileRecords;

    require "vendor/autoload.php";

    $fr = new FileRecords("test.dat",8);

    $fr->appendRecord("01234567");
    $fr->appendRecord("Abc defg");

    echo $fr->recordsCount();
    // 2

    echo $fr->readRecord(1);
    // Abc defg
    echo $fr->readRecord(0);
    // 01234567

    $fr->reWriteRecord(1,"lala lal");
    echo $fr->readRecord(1);
    // lala lal