Skip to content

Little php extension, for read file and return simple object contains array of each line

License

Notifications You must be signed in to change notification settings

simon88/php_extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Php extension

This simple extension, take 2 arguments, first is the name of the file and second is buffer size. This simple extension read file and create simple object with two property :

  • First propety is the number of line
  • Second is an array of line

How compile

On linux you need php5-dev, to install use this command line : apt-get install php5-dev

phpize5
./configure
make

After make command new folder is create, name is "modules", in this folder you can find .so file, this file is the nex extension.

Next step, load new extension, move in modules folder :

echo extension=`pwd`/myext.so >/etc/php5/mods-available/myext.ini
php5enmod myext
/etc/init.d/apache2 restart

How to test

Create php file and txt file with some lines. And add this line in your php file

<?php

var_dump(read_file("file.txt", 1024));

Enjoy, you have new object with an array containing all the lines and the number of lines !

About

Little php extension, for read file and return simple object contains array of each line

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published