note 101245 modified in function.dba-fetch by danbrown

From: Date: Sun, 05 Dec 2010 16:42:28 +0000
Subject: note 101245 modified in function.dba-fetch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174625@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 <?php # 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 --was-- :: 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 http://php.net/manual/en/function.dba-fetch.php

« previous php.notes (#174625) next »