PHP implementation of random IP function "Domestic IP segment" _php skills

Source: Internet
Author: User
Tags php programming php regular expression rand

This article illustrates the random IP function of PHP implementation. Share to everyone for your reference, specific as follows:

function Get_rand_ip () {
  $arr _1 = Array ("218", "218", "66", "66", "218", "218", "60", "60", "202", "204", "66", "66", "66" , "222", "221", "the" "," "", "" "," "," "," "," "," "," "218", "218", "," "," "," "," "," "," "122", "211");
  $randarr = Mt_rand (0,count ($arr _1));
  $ip 1id = $arr _1[$randarr];
  $ip 2id=  Round (rand (600000,  2550000)  /  10000);
  $ip 3id=  Round (rand (600000,  2550000)  /  10000);
  $ip 4id=  Round (rand (600000,  2550000)  /  10000);
  return  $ip 1id. "." . $ip 2id. "." . $ip 3id. "." . $ip 4id;
}
Echo get_rand_ip ();//output: 211.104.85.78

More interested in PHP related content readers can view the site topics: "PHP Network Programming Skills Summary", "Php Curl Usage Summary", "PHP Socket Usage Summary", "PHP Regular Expression Usage summary", "PHP string (String) Usage Summary", " PHP array Operation techniques Encyclopedia, "PHP Mathematical Calculation Skills Summary", "PHP object-oriented Programming Introductory Course", "PHP Data structure and algorithm tutorial", "PHP Programming algorithm Summary" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.