note 37820 deleted from function.dbase-get-record by didou

From: Date: Sat, 29 Jan 2005 23:31:31 +0000
Subject: note 37820 deleted from function.dbase-get-record by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-84180@lists.php.net to get a copy of this message
Note Submitter: guillaume_dot_sueur_at_geosignal_dot_fr ---- The function dbase_get_record as well as dbase_get_record_with_names send back the content of the field on its full length. That's why you need to trim or chop it to use it. Example (let's say we have a 10 char length field) : $nr = dbase_numrecords($fp); // Number of records. for ($i=1; $i <= $nr; $i++) { $rec = dbase_get_record($fp,$i); if ($rec [0] == "TEST") // evaluation of the content of the fields against "TEST" word. //This can't work because it evaluates "TEST " (10 char length) against "TEST" (target value) { echo "TEST Found in file"; // will never happen ! exit; } // now the correct manner : if (chop($rec [0]) == "TEST") { echo "TEST Found in file"; // will happen ! exit; } } dbase_close($fp);

« previous php.notes (#84180) next »