1. Go to this page and download the library: Download totalcrm/php-dbf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
totalcrm / php-dbf example snippets
use TotalCRM\DBase\TableReader;
$table = new TableReader('test.dbf');
while ($record = $table->nextRecord()) {
echo $record->get('my_column');
//or
echo $record->my_column;
}
use TotalCRM\DBase\TableReader;
$table = new TableReader(
'test.dbf',
[
'encoding' => 'cp1251'
]
);
use TotalCRM\DBase\TableReader;
$table = new TableReader(
'test.dbf',
[
'columns' => ['my_column', 'another_column']
]
);
while ($record = $table->nextRecord()) {
echo $record->my_column;
echo $record->another_column;
}
while ($record = $table->nextRecord()) {
echo $record->get('my_column');
echo $record->get('another_column');
}
use TotalCRM\DBase\TableEditor;
$table = new TableEditor('test.dbf');
for ($i = 0; $i < 10; $i++) {
$record = $table->nextRecord();
$record->set('field', 'string');
//or
$record->field = 'string';
$table->writeRecord();
}
$table
->save()
->close();