random assessment

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mnewman
Forum Newbie
Posts: 10
Joined: Tue Sep 20, 2011 7:53 pm

random assessment

Post by mnewman »

how can i randomize my assessment in every load of the page?
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: random assessment

Post 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.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: random assessment

Post 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)
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: random assessment

Post 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!
User avatar
mnewman
Forum Newbie
Posts: 10
Joined: Tue Sep 20, 2011 7:53 pm

Re: random assessment

Post by mnewman »

.,thanks guys
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: random assessment

Post 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.
User avatar
mnewman
Forum Newbie
Posts: 10
Joined: Tue Sep 20, 2011 7:53 pm

Re: random assessment

Post 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
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: random assessment

Post 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
User avatar
mnewman
Forum Newbie
Posts: 10
Joined: Tue Sep 20, 2011 7:53 pm

Re: random assessment

Post 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.
Post Reply