FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


IP Generation





fromegame
Hello Again Laughing

I need a script that generates max. 12 random numbers.
Like an IP Address.

x = generated number

xxx.xxx.xxx.xxx

But if x = 0 then it must not be showed, so if x = 0 and y != 0

(x)yy.yyy.yyy.yyy

Thank You Wink
DanielXP
PHP.net rand()
fromegame
Yes I know, but how can I get all those rands in 1 variable?
hexkid
fromegame wrote:
how can I get all those rands in 1 variable?

With the concatenation operator
Code:
$var1 = rand();
$var2 = rand();
$var3 = rand();

$x = $var1 . '.' . $var2 . '.' . $var3;
$y = "$var1.$var2.$var3";
snowboardalliance
hexkid wrote:
fromegame wrote:
how can I get all those rands in 1 variable?

With the concatenation operator
Code:
$var1 = rand();
$var2 = rand();
$var3 = rand();

$x = $var1 . '.' . $var2 . '.' . $var3;
$y = "$var1.$var2.$var3";


Code:
$var1 = rand(0,999);
$var2 = rand(0,999);
$var3 = rand(0,999);
$var4 = rand(0,999);

$x = $var1 . '.' . $var2 . '.' . $var3 . '.' . $var4;
$y = "$var1.$var2.$var3.$var4";

Will work if you want three digits max (i.e. "234.555.8.14")
Or change the 0,999 to whatever values.
Related topics
Visitor ip PHP (E107)
ip address
ip
.htaccess IP Blocking
PHP IP Ban
IP forewarding
Cannot determine nameserver ip
php script sows Ip
ip looking
Ip Banning Using Php
Introduction Generation 2k
your weekly dose of fascism. Internet2 not for you?
FTP problem: 500 I won't open a connection to [internal IP]
:?: IP's from ns1.frihost.net and ns2.frihost.net
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.