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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-15-2008, 04:27 PM   #1
qxm
Confirmed User
 
Join Date: Jul 2006
Location: NoHo
Posts: 5,970
Need Some Quick PHP Help...PHP Gurus Inside!

So I have an array like this:

PHP Code:
$dic = array(
" integer1 " => " integer2 ",
" integer3 " => " integer4 ",
" integer5 " => " integer6 ",
" integer7 " => " integer8 ",
); 
and I need to asign 3 different possible values to each element of the array so that the script will randomly choose one...... how can I rewrite this array? ... will an array be even the right choice here?

I need something like this (don't know if this is even possible when it comes to arrays):

PHP Code:
$dic = array(
" integer1 " => " integerA " " integerB " " integerC ",
" integer3 " => " integerD " " integerE " " integerF ",
" integer5 " => " integerG " " integerH " " integerI ",
" integer7 " => " integerJ " " integerK " " integerL ",
); 
If integer1 is found the script should access and set a random value within the array...any ideas of how to set this up?
__________________

ICQ: 266990876
qxm is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 04:38 PM   #2
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
you need to do a multi-dimensional array
$dic = array( "interger1 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ), "interger2 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ), "interger3 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ));

then shuffle();

edit: good chance i fucked that code up because im half asleep, but you'll get the idea im sure.

Last edited by k0nr4d; 06-15-2008 at 04:39 PM..
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 04:40 PM   #3
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
use array_rand()

say you have $pick = array('integerA', 'integerB', 'integerC');
then use with your $dic = array(
'integer1'=>array_rand($pick),
'integer2'=>array_rand($pick),
...
);

hope this helps
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 04:42 PM   #4
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
i think i'm a bit off as i didn't quite get what you wanted pull randomly, but you get the idea..
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 04:42 PM   #5
qxm
Confirmed User
 
Join Date: Jul 2006
Location: NoHo
Posts: 5,970
Quote:
Originally Posted by k0nr4d View Post
you need to do a multi-dimensional array
$dic = array( "interger1 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ), "interger2 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ), "interger3 " => array( "intergerA" => "value", "intergerB" => "value", "intergerC" => "value" ));

then shuffle();

edit: good chance i fucked that code up because im half asleep, but you'll get the idea im sure.
multidimensional.. that rings some bells ....
__________________

ICQ: 266990876
qxm is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 04:46 PM   #6
qxm
Confirmed User
 
Join Date: Jul 2006
Location: NoHo
Posts: 5,970
Quote:
Originally Posted by holograph View Post
i think i'm a bit off as i didn't quite get what you wanted pull randomly, but you get the idea..
I need that when integer1 is found the script will go into the array and pic 1 of 3+ possible values specified for that array element........ for instance

IF

integer1 is found it shoud pick 1 of 3+ values and assign it to it... the script should asign a value to each integer element so: integer2, integer3, integer4 will also be assigned a value..
__________________

ICQ: 266990876

Last edited by qxm; 06-15-2008 at 04:47 PM..
qxm is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-15-2008, 05:00 PM   #7
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
yeah, then do them multidimentional as k0nr4d said and then use shufle or array_rand to pick random value for required integer
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.