PHP實現(xiàn)的隨機IP函數(shù)【國內(nèi)IP段】
本文實例講述了PHP實現(xiàn)的隨機IP函數(shù)。分享給大家供大家參考,具體如下:
function get_rand_ip(){ $arr_1 = array("218","218","66","66","218","218","60","60","202","204","66","66","66","59","61","60","222","221","66","59","60","60","66","218","218","62","63","64","66","66","122","211"); $randarr= mt_rand(0,count($arr_1)); $ip1id = $arr_1[$randarr]; $ip2id= round(rand(600000, 2550000) / 10000); $ip3id= round(rand(600000, 2550000) / 10000); $ip4id= round(rand(600000, 2550000) / 10000); return $ip1id . "." . $ip2id . "." . $ip3id . "." . $ip4id; } echo get_rand_ip();//輸出:211.104.85.78
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《php curl用法總結(jié)》、《php socket用法總結(jié)》、《php正則表達式用法總結(jié)》、《php字符串(string)用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP數(shù)學(xué)運算技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計算法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家PHP程序設(shè)計有所幫助。
相關(guān)文章
詳談php ip2long 出現(xiàn)負數(shù)的原因及解決方法
下面小編就為大家?guī)硪黄斦刾hp ip2long 出現(xiàn)負數(shù)的原因及解決方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04PHP排序之二維數(shù)組的按照字母排序?qū)崿F(xiàn)代碼
PHP排序之二維數(shù)組的按照字母排序方法,在實際開發(fā)還是非常有用的,有需要的拿去2011-08-08