note 37820 added to function.dbase-get-record

From: Date: Fri, 28 Nov 2003 13:27:51 +0000
Subject: note 37820 added to function.dbase-get-record
Groups: php.notes 
Request: Send a blank email to php-notes+get-61071@lists.php.net to get a copy of this message
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); ---- Manual Page -- http://www.php.net/manual/en/function.dbase-get-record.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37820 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37820&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37820&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61071) next »