PHP Classes

PHP File Access: Access and manipulate files

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 86 All time: 9,993 This week: 488Up
Version License PHP version Categories
php-file-access 1.0Custom (specified...5PHP 5, Files and Folders


This package can access and manipulate files.

It provides a PHP iteration that acts like an array and also counts file elements that it contains by sorting or modifying the files.

The class main goal is to act as an alternative to the PHP file function by providing more delimiter options.

Picture of zinsou A.A.E.Mo´se
  Performance   Level  
Name: zinsou A.A.E.Mo´se is available for providing paid consulting. Contact zinsou A.A.E.Mo´se .
Classes: 50 packages by
Country: Benin Benin
Age: 34
All time rank: 6781 in Benin Benin
Week rank: 115 Up1 in Benin Benin Equal
Innovation award
Innovation award
Nominee: 23x

Winner: 2x


require 'FileAccess.class.php';

$x=new FileAccess(__FILE__,'\n');

// $x->getMimeType(),
   // $x->getMd5(),
   // $x->getSha1(),
   // $x->end(),
   // $x->key(),
   // $x->count(),
count($x) ,
// $x[1],
   // $x->fstat(),
   // $x->max_chunk_length(),
   // $x->length(),
   // array_map('htmlspecialchars',$x->getArrayCopy()),
   // $x->getMoreOptions(),
   // $x->getMoreinfos(),
   // $x->ftell(),
    // $x->seek(265),
   // $x->current(),
   // $x->prev() ,
   // $x->current() ,
// ,
   // $x->offsetGet(31) ,
   // $x->offsetExists(28),
   // $x->fseek(50),
   // $x->ftell() ,
   // $x->fread(512),
   // $x->reset(),
   // $x->fscanf( "%s",$php),
   // $x->fgets(),
   // htmlspecialchars($php) ,
   // $x->rewind(),
        // htmlspecialchars($x->current()),
    // $x->next(),
    // $x->current(),
    // $x->prev(),
    // $x->current()
// $x->fpassthru() ;
        echo htmlspecialchars($x->current()), "\n"; $x->next();

     echo htmlspecialchars($x->current()), "\n";


        echo htmlspecialchars($x->current()), "\n";

    foreach($x ->Filter_FileAccess() as $k=>$l){
         echo $k.':'.htmlspecialchars($l);
foreach($x as $k=>$v){


FileAccess is a seek-able countable PHP Iterator that acts too in part like an ArrayObject.It meanly act as a read only ArrayObject that can't be sorted or modify. Its main goal is to act as a flexible and inexpensive alternative to the PHP file function providing more delimiter options.It actually have all the read-only file functions and can help to iterate on a chosen format of file's chunks. class FileAccess implements SeekableIterator,countable,ArrayAccess { protected $fileHandle, $delimiter, $lines=[], $length, $flags, $line, $i=0, $spl_info, $spl_options, $max_line_length, $context, $path; public function __construct(string $fileName,string|integer|float $delimiter='\n',int $flags=0,resource $context=null) $delimiter can be a POSIX regex public function rewind() public function valid() public function current() public function key() public function next() public function prev() public function eof() public function end() public function count() public function offsetExists(int $offset) public function offsetGet(int $offset) public function offsetSet(int $offset,mixed $value) public function offsetUnset(int $offset) public function seek(int $offset) public function ftell() public function fseek(int $offset,int $whence=SEEK_SET) public function fread(int $length) public function fgets(int $length=null) public function fgetc() public function fgetss(int $length=null,string $allowable_tags='') public function fscanf(string $format,&...$facultatives) Only for PHP >=5.6.0,open the class file and comment this method lines if you use PHP < 5.6 public function fgetcsv(int $length = 0 ,string $delimiter = "," ,string $enclosure = '"' ,string $escape = "\\" ) public function reset() public function fpassthru( public function Filter_FileAccess() only usefull to act like PHP "file" function : filter with defined flags when $delimiter=='\n' and return unfiltered data when !='\n' public function getArrayCopy() return an array containing the iterator values(eg: when $delimiter is \n then the array will be the same as the PHP file function output without flags skip_empty_lines and ignore_new_line public function fstat() public function length public function max_chunk_length() public function getMoreInfos() return new SplFileInfo object public function getMoreOptions(string $mode="rb",boolean $use_include_path=false) return new SplFileObject object with read only mode public function getMimeType() public function getSha1(boolean $raw_output=false) public function getMd5(boolean $raw_output=false) public function __toString() public function __destruct() } report bugs and improvements to or simply use the dedicated forum.

  Files folder image Files  
File Role Description
Plain text file FileAccess.class.php Class class source
Accessible without login Plain text file license.txt Lic. license file
Accessible without login Plain text file readme.txt Doc. readme
Accessible without login Plain text file testFileAccess.php Example example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,993
This week:488Up