PHP code example of gregorj / randomip

1. Go to this page and download the library: Download gregorj/randomip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gregorj / randomip example snippets



//echos a random class B (172.[16-31].0.0/12) network for 6 hosts.
echo \GregorJ\RandomIP\RandomPrivateIPv4::randomNetwork('B', 29);

//echos a random IP address inside the network 192.168.21.0/24
echo \GregorJ\RandomIP\RandomPrivateIPv4::randomIP("192.168.21.0", 24);