What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



dbase_pack — Packs a dbf file.


bool dbase_pack(dbf_identifier);
int dbf_identifier: dbf identifier


TRUE on success; FALSE on error


dbase_pack() packs a dbf file - removing all records that have been marked for deletion by dbase_delete_record() and removing the empty space left by the record's deletion.

The dbf file refered to by dbf_identifier must have been opened in write (1) or read/write (2) mode for dbase_pack to succeed.


PHP Version: 3+, 4+


Example 231. Pack a dbf file and display a summary of the changes

# Path to dbf file
$db_file = '/tmp/sushi_eaten.dbf';

# Open dbf file for reading and writing
$id = @ dbase_open ($db_file, 2)
    or die ("Could not open dbf file <i>$db_file</i>."); 

# Find the number of rows in the dbf file
$num_rows = dbase_numrecords ($id);

# Loop through the dbf file before using dbase_pack()
for ($i=1; $i <= $num_rows; $i++)
    $before[] = dbase_get_record ($id, $i);

# Pack the dbf file
dbase_pack ($id)
    or die ("Could not pack dbf file <i>$db_file</i>.
        Make sure that the file was opened in write (1) or read/write (2) mode."); 

# Find the number of rows in the dbf file
$num_rows = dbase_numrecords ($id);

# Loop through the dbf file after using dbase_pack()
for ($i=1; $i <= $num_rows; $i++)
    $after[] = dbase_get_record ($id, $i);

# Display the entries removed by dbase_pack()
print "These items were removed from dbf file <i>$db_file</i><blockquote>";
print_r (array_diff ($before, $after));
print '</blockquote';

# Close the dbf file
dbase_close ($id);

PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.