note 101245 added to function.dba-fetch
| From: | khan666 at lycos dot co dot kr | Date: | Sun, 05 Dec 2010 13:11:11 +0000 |
| Subject: | note 101245 added to function.dba-fetch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174618@lists.php.net to get a copy of this message | ||
:: fetch array sort.
ex) TEST_DATA.DB
1/korea/5000/word 1
10/japan/25000/word 10
21/china/130000/word 21
2/usa/35000/word 2
<?
# LIST SORT
$DB4_DATABASE = "TEST_DATA.DB4";
$DIV = "/";
$_FILE = "$DATA_DIR/HUTM_NETWORK_ROUTER.DB"; // DB4 FileName
$db = dba_open($DB4_DATABASE,"r","db4");
$key = dba_firstkey($db);
$ii = 0;
while($key != NULL)
{
$LIST[$ii] = explode($DIV,dba_fetch($key, $db)); // fetch array
$key = dba_nextkey($db);
$ii++;
}
dba_close($db);
$total = $ii; // total count
# date sort
sort($LIST,SORT_NUMERIC); // numeric key sort ..
# list display
for($i=0;$i<$total;$i++)
{
$oData = explode($DIV,$LIST[$i]); // key + value (sort)
$key = trim(chop($oData[0])); # í¤ë²í¸
$name = trim(chop($oData[1])); # ì´ë¦
$count = trim(chop($oData[2])); # ì
$word = trim(chop($oData[3])); # ì¤ëª
echo "$key / $name / $count / $word <br>\r\n";
}
?>
::result::
1/korea/5000/word 1
2/usa/35000/word 2
10/japan/25000/word 10
21/china/130000/word 21
----
Server IP: 211.234.110.150
Probable Submitter: 112.144.96.198
----
Manual Page -- http://www.php.net/manual/en/function.dba-fetch.php
Edit -- https://master.php.net/note/edit/101245
Del: integrated -- https://master.php.net/note/delete/101245/integrated
Del: useless -- https://master.php.net/note/delete/101245/useless
Del: bad code -- https://master.php.net/note/delete/101245/bad+code
Del: spam -- https://master.php.net/note/delete/101245/spam
Del: non-english -- https://master.php.net/note/delete/101245/non-english
Del: in docs -- https://master.php.net/note/delete/101245/in+docs
Del: other reasons-- https://master.php.net/note/delete/101245
Reject -- https://master.php.net/note/reject/101245
Search -- https://master.php.net/manage/user-notes.php