note 130021 added to book.dbase

From: Date: Tue, 11 Feb 2025 20:19:16 +0000
Subject: note 130021 added to book.dbase
Groups: php.notes 
Request: Send a blank email to php-notes+get-221843@lists.php.net to get a copy of this message
no need to install an extension deleted records are also taken in account function dBase() { $fdbf = fopen($dbfname,'r'); // REAONLY $buf = fread($fdbf,32); $header=unpack( "VRecordCount/vFirstRecord/vRecordLength", substr($buf,4,8)); $fields = array(); $field = array("fieldname" => "DELETED ", "fieldtype" => "C", "offset" => 1, "fieldlen" => 1, "fielddec" => 0,); array_push($fields, $field); $unpackString='A1DELETED/'; $goon = true; while ( $goon && !feof($fdbf) ) { // read fields: $buf = fread($fdbf,32); if ( substr($buf,0,1)==chr(13) ) { $goon=false; } else { $field=unpack( "a11fieldname/A1fieldtype/Voffset/Cfieldlen/Cfielddec", substr($buf,0,18)); $unpackString.="A$field[fieldlen]$field[fieldname]/"; array_push($fields, $field); } } // end while goon fseek($fdbf, $header['FirstRecord']+0); for ( $i=1; $i<=$header['RecordCount']; $i++ ) { $buf = fread($fdbf,$header['RecordLength']); // ORIG $record=unpack($unpackString,$buf); print_r($record); // and do other stuff } // for $i fclose($fdbf); } // end function dBase ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 2a02:1810:2f0d:1300:e0a1:93d7:d8e:8ac2) ---- Manual Page -- https://php.net/manual/en/book.dbase.php Edit -- https://main.php.net/note/edit/130021 Del: integrated -- https://main.php.net/note/delete/130021/integrated Del: useless -- https://main.php.net/note/delete/130021/useless Del: bad code -- https://main.php.net/note/delete/130021/bad+code Del: spam -- https://main.php.net/note/delete/130021/spam Del: non-english -- https://main.php.net/note/delete/130021/non-english Del: in docs -- https://main.php.net/note/delete/130021/in+docs Del: other reasons-- https://main.php.net/note/delete/130021 Reject -- https://main.php.net/note/reject/130021 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221843) next »