![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Dec 2001
Posts: 7,952
|
Php help needed.
Does someone know how you do this
I'd like to generate 10 random #'s 1 thru 100 and atleast a gap of 4 apart. None can be a duplicate of the other. Anyone know how to do that? Thanks |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jul 2003
Posts: 2,868
|
Yes, Pay me
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Nov 2001
Location: MTL
Posts: 5,060
|
hmm basically you just need the rand(1,100) function and you test the result with your conditions...
__________________
mmm my sig was too big... no more cool animation ![]() but hey still! need php? ICQ: 94586959 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Industry Role:
Join Date: Feb 2003
Location: Australia
Posts: 9,492
|
Quote:
![]()
__________________
![]() Blue Design Studios - Adult Design Specialists! Email me for a free quote: [email protected] |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Jul 2003
Posts: 2,868
|
srand function go read on it at php.net
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Join Date: Nov 2001
Location: MTL
Posts: 5,060
|
Quote:
![]() I'm assuming he knows how to do while() with conditions...etc...if not then he needs someone to do the script...not some help with it..! ;-) then I could do it...but we get back to the previous point...it's 4am... i'm tired... LOL
__________________
mmm my sig was too big... no more cool animation ![]() but hey still! need php? ICQ: 94586959 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Feb 2003
Location: Canby, OR
Posts: 7,453
|
Quote:
jDoG
__________________
NSCash now powering ReelProfits.com ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash NOW OFFERING OVER 60 SITES CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133) |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Jul 2002
Location: Fort Lauderdale
Posts: 600
|
Okay this covers your requirements, gives you 10 randomly generated numbers, at least 4 digits away from any other number it previously gave you.
$uniq=array(); function four_or_more_apart($number,$array){ $keys=array_keys($array); for ($x=0; $x<count($keys);$x++){ if ($number-4<$keys[$x] && $number+4>$keys[$x]){ return 0; } } return 1; } while($counter<10){ $number = rand(1,100); if (!$uniq[$number] && four_or_more_apart($number,$uniq)){ $uniq[$number]++; print "$number\n"; $counter++; } } Kind of curious what yah need it for though... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Registered User
Join Date: Jul 2003
Posts: 77
|
my beautiful contribution
PHP Code:
__________________
icq: 201430673 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Industry Role:
Join Date: Dec 2001
Posts: 7,952
|
I want to rotate in random sponsor galleries. I could just hardcode certain spots to be sponsors but I figured doing it random might improve my productivity? Plus new code always helps me somewhere else and I become better at php.
I appreciate the help and when I get going i'll test it out tommorow what was posted. Thanks |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Join Date: Apr 2003
Posts: 315
|
try ghostdriver
|
![]() |
![]() ![]() ![]() ![]() ![]() |