|
 |
|
วานผู้รู้ช่วยแนะนำทีครับ ผมมี log.text อยู่ 1 ไฟล์น่ะครับข้างในประมาณนี้ |
|
 |
|
|
 |
 |
|
ผมมี log.text อยู่ 1 ไฟล์น่ะครับข้างในประมาณนี้
a,20,192.168.16.106,32
b,90,192.168.16.136,44
c,70,192.168.16.136,55
d,80,192.168.16.136,22
e,50,192.168.16.156,14
e,50,192.168.16.156,14
e,50,192.168.16.176,14
ครับ คือโจทย์ให้ดึงเอา ip และก็จำนวน ip ที่มีในระบบโดยการเขียนโปรแกรมเรียกขึ้นมาซึ่งคำตอบมีดังนี้
ip frequency
192.168.16.106 1
192.168.16.136 3
192.168.16.156 2
192.168.16.176 1
code ของผมมันไม่ยอมอ่านบรรทัดล่างสุดอ่ะครับ คือ 3 ip บนมันอ่านและคำนวณมาแล้วช่วยชี้แนะด้วยครับ
<?
$read = fopen("log.txt","r");
echo "<table border = 1>";
echo "<tr><td>ip</td><td>frequency</td></tr>";
$line = fgets($read);
$str = explode(",",$line);
$check = $str[2];
$num = 0;
//echo $check;
while(feof($read) == false)
{
//$check[$i] = $str[2];
if( $check == $str[2])
{
$num++;
$line = fgets($read);
$str = explode(",",$line);
}
else{
echo "<tr><td>".$check."</td><td>".$num."</td></tr>" ;
$num = 0;
$check = $str[2];
}
//$i++ ;
}
echo "</table>";
fclose($read);
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-07-18 12:35:55 |
By :
man2531 |
View :
930 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่ค่อยเข้าใจ อธิบายให้มันกระจ่างหน่อยคับ
คุณต้องการอะไร
ฟีลของข้างบนมีอะไรบ้าง a,20,192.168.16.106,32
แล้วข้างล่างคืออะไร 192.168.16.106 1
|
 |
 |
 |
 |
Date :
2009-07-18 19:01:11 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|