GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Need Some Quick PHP Help...PHP Gurus Inside! (https://gfy.com/showthread.php?t=835029)

qxm 06-15-2008 04:27 PM

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?

k0nr4d 06-15-2008 04:38 PM

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.

Serge Litehead 06-15-2008 04:40 PM

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 06-15-2008 04:42 PM

i think i'm a bit off as i didn't quite get what you wanted pull randomly, but you get the idea..

qxm 06-15-2008 04:42 PM

Quote:

Originally Posted by k0nr4d (Post 14322762)
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 .... :thumbsup

qxm 06-15-2008 04:46 PM

Quote:

Originally Posted by holograph (Post 14322770)
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..

Serge Litehead 06-15-2008 05:00 PM

yeah, then do them multidimentional as k0nr4d said and then use shufle or array_rand to pick random value for required integer


All times are GMT -7. The time now is 05:54 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123