| 作者 |
主題 |
dc
管理員

性別:男
來自:瓦肯星
發表總數:11790
註冊時間:2002-05-07 16:32 |
(第 1 篇) 【討論】如何改寫用 file_get_contents 取得的資料?
請問大家關於 PHP 的問題~偶遇到瓶頸了不知道要怎麼寫判斷式....
下面的代碼是將 韓國的 ip 範圍截取出來
| 代碼: |
<?
//韓國 IP 列表網頁
$url="http://ipstat.nida.or.kr/korea_ip/korea_ip4_data.jsp";
//遠端開啟網頁
$content=file_get_contents($url);
//只取<td>*.*.*.*</td> IP位置
preg_match_all("|<[td>]+>([0-9].[0-9].[0-9].*)</[td>]+>|U",$content,$title);
//循環取得 IP 位置
for ($i=0; $i< count($title[0]); $i++) {
echo $title[1][$i]."<br>";
}
?>
|
可是因為是要設定在 ip sec 裡~需要把
202.6.95.0
202.6.95.255
改成 202.6.95.*
163.239.0.0
163.239.255.255
改成 163.239.*.*
202.20.83.0
202.20.86.255
改寫成
202.20.83.*
202.20.84.*
202.20.85.*
202.20.86.*
如此~~但是 if 的判斷式我試了好久都不知道要怎麼下 XD
先謝謝大家了
本帖由dc最後編輯於2008-09-23 18:06
Your mind to my mind,
your thought to my thought |
| 發表時間:2008-09-23 18:05 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11790
註冊時間:2002-05-07 16:32 |
(第 2 篇)
資料來源:PHP5討論區
底下是列出 192.168.4.1 ~ 192.168.5.200 的範圍
| 代碼: |
<?php
$ip_start = '192.168.4.1';
$ip_end = '192.168.5.200';
$strStart = ($ip_start < $ip_end) ? $ip_start : $ip_end;
$strEnd = ($ip_start > $ip_end) ? $ip_start : $ip_end;
$a=ip2long($strStart);
$b=ip2long($strEnd);
for($x=$a;$x<=$b;$x++){
echo long2ip($x)."\<br />";
}
?>
|
單純 from 192.168.1.1 to 192.168.1.5
| 代碼: |
<?php
for($i=1;$i<6;++$i){echo "192.168.1.".$i."</br>";}
?>
|
本帖由dc最後編輯於2008-09-23 18:32
Your mind to my mind,
your thought to my thought |
| 發表時間:2008-09-23 18:31 |
|
dc
管理員

性別:男
來自:瓦肯星
發表總數:11790
註冊時間:2002-05-07 16:32 |
(第 3 篇)
問題解決囉~請看站內文章~
http://omega.idv.tw/kdb120/viewthread.php?threadid=3893
Your mind to my mind,
your thought to my thought |
| 發表時間:2008-09-24 21:19 |
|
|
所有時間均為GMT+8, 現在是2026-10-24 18:51 |