<?php
require("../../phplibex.inc.php");
$file = new file();
$filename = "test.txt";
$data = "Time |Date |Value\n";
$data .= "08:01:00 |2005-01-01 |1\n";
$data .= "08:02:00 |2005-01-02 |2\n";
$data .= "08:03:00 |2005-01-03 |3\n";
$data .= "08:04:00 |2005-01-04 |4\n";
$data .= "08:05:00 |2005-01-05 |5\n";
$data .= "08:06:00 |2005-01-06 |6\n";
$data .= "08:07:00 |2005-01-07 |7\n";
$data .= "08:08:00 |2005-01-08 |8\n";
$data .= "08:09:00 |2005-01-09 |9\n";
$data .= "08:10:00 |2005-01-10 |10";
if ( $file->file_check($filename) );
$file->file_delete($filename);
$file->file_append( $filename, $data );
echo "<b>File size in kByte: </b>".$file->file_getsize($filename)."<br>";
echo "<b>File size in Byte : </b>".$file->file_getsize_byte($filename)."<br>";
echo "<b>Number of lines: </b>".$file->file_nrlines($filename)."<br><br>";
echo "<b>File header: </b>".$file->file_getheader($filename)."<br><br>";
$column = $file->file_get_column( $filename, 1, "|" );
echo "<b>Column 1:</b><br>";
for ( $loop=0; $loop<=sizeof($column)-1; $loop++ )
echo $column[$loop]."<br>";
$column = $file->file_get_column_reverse( $filename, 1, "|" );
echo "<br><b>Column 1 reverse:</b><br>";
for ( $loop=0; $loop<=sizeof($column)-1; $loop++ )
echo $column[$loop]."<br>";
echo "<br><b>Show complete data as string:</b><br>";
echo $file->file_getdata_normal($filename);
$data = $file->file_getdata($filename);
echo "<br><br><b>Show complete data as array:</b><br>";
for ( $loop=0; $loop<=sizeof($data)-1; $loop++ )
echo $data[$loop]."<br>";
?>