作者KoalaLee (Co-a)
看板PttCurrent
標題Re: 關於版區文章列表
時間Tue Aug 10 19:53:51 2004
※ 引述《ronald.bbs@ip-212-80-134-202.rev.dyxnet.com (朗奴)》之銘言:
: 如果以fileheader_t為例, 能不能給我一個提示呢??
: 因為我之前也有研究用unpack()來解.DIR
: 但總是不成功, 而改用了比較慢的方法處理, 而且資料
: 型態的轉換變得相當麻煩
<?php
$fp = fopen("c:/test.ACCT", "rb");
$binary = fread($fp, 224);
$acct = unpack("iuserno/a13userid/a14passwd/a20realname/a24username/x"
."/Iuserlevel/Iufo/Csignature/Cuserrank/cyear/cmonth/cday/csex/x2"
."/imoney/igold/Inumpoints/inumlogins/inumposts/inumemails"
."/ifirstlogin/ilastlogin/itcheck/itvalid/"
."a30lasthost/a60email", $binary);
print_r($acct);
?>
這是我之前弄的, 大致上就是 第一位是型態, 型態的數字接著個數, 再來是變數名稱
沒有個數代表一個, C語言的字串用 a為型態, x用來對齊位置的
a14passwd 表示 以 null 為結尾的字串長 14 字元, 變數名稱 passwd
---------- PHP Excute ----------
Array
(
[userno] => 367
[userid] => test
[passwd] => asdfasdfasdfa
[realname] => 摳阿拉...
[username] => test
[userlevel] => 17
[ufo] => 90192
[signature] => 0
[userrank] => 0
[year] => 0
[month] => 0
[day] => 0
[sex] => 0
[money] => 123
[gold] => 0
[numpoints] => 0
[numlogins] => 2
[numposts] => 0
[numemails] => 0
[firstlogin] => 1089849910
[lastlogin] => 1089852372
[tcheck] => 1089849910
[tvalid] => 1089849977
[lasthost] => somewhere.cse.ttu.edu.tw
[email] => whatever@kkc.ttu.edu.tw
)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.92.70
→ KoalaLee:Btw, struct不大一樣....so... 220.135.92.70 08/10
→ KoalaLee:用 / 分開各個變數 220.135.92.70 08/10