Page 1 of 1

random assessment

Posted: Thu Sep 22, 2011 11:08 pm
by mnewman
how can i randomize my assessment in every load of the page?

Re: random assessment

Posted: Thu Sep 22, 2011 11:19 pm
by flying_circus
My crystal ball is out for service, but if you want real advice, you're going to need to be a bit more descriptive.

Re: random assessment

Posted: Fri Sep 23, 2011 12:14 am
by twinedev

Code: Select all

<?php

	$strMessage = 'my assessment';
	$aryKeys = range(0,strlen($strMessage)-1);
	shuffle($aryKeys);
	$strRandom = '';
	foreach($aryKeys as $index) {
		$strRandom .= $strMessage{$index};
	}
	echo "$strRandom\n";

?>
(LOL, little loopy from being sick)

Re: random assessment

Posted: Fri Sep 23, 2011 11:49 am
by flying_circus
twinedev wrote:

Code: Select all

<?php

	$strMessage = 'my assessment';
	$aryKeys = range(0,strlen($strMessage)-1);
	shuffle($aryKeys);
	$strRandom = '';
	foreach($aryKeys as $index) {
		$strRandom .= $strMessage{$index};
	}
	echo "$strRandom\n";

?>
(LOL, little loopy from being sick)
Hah! I wasn't expecting that. Good one!

Re: random assessment

Posted: Fri Sep 23, 2011 11:21 pm
by mnewman
.,thanks guys

Re: random assessment

Posted: Sat Sep 24, 2011 12:27 am
by twinedev
Was just being silly while waiting for more details on what you were actually looking for.... Like I said, was pretty loopy at the time... And getting that way again from only 2 hour nap since getting up about 38 hours ago.

Re: random assessment

Posted: Sat Sep 24, 2011 2:01 am
by mnewman
twinedev wrote:

Code: Select all

<?php

	$strMessage = 'my assessment';
	$aryKeys = range(0,strlen($strMessage)-1);
	shuffle($aryKeys);
	$strRandom = '';
	foreach($aryKeys as $index) {
		$strRandom .= $strMessage{$index};
	}
	echo "$strRandom\n";

?>
(LOL, little loopy from being sick)
ohh..not the string.,what i mean is the item

Re: random assessment

Posted: Sat Sep 24, 2011 4:30 am
by twinedev
"how can i randomize my assessment in every load of the page?"

That is what we need defined to know what you are trying to randomize.

-Greg

Re: random assessment

Posted: Sat Sep 24, 2011 4:37 am
by mnewman
@twinedev

its ok, i already got the right logic of it..but there is another problem.. how can i escape / unpost some duplicate of my query??
coz i use the rand() function and loop it.