1. Go to this page and download the library: Download hisamu/php-xbase 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/ */
hisamu / php-xbase example snippets
use XBase\TableReader;
$table = new TableReader('test.dbf');
while ($record = $table->nextRecord()) {
echo $record->get('my_column');
//or
echo $record->my_column;
}
use XBase\TableReader;
$table = new TableReader(
'test.dbf',
[
'encoding' => 'cp1251'
]
);
use XBase\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 XBase\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();