Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-13-2003, 11:09 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
randomize array

how can i randomize an array?

shuffle() is the only function i can find, however that doesn't work.
sde is offline   Reply With Quote
Old 03-13-2003, 03:44 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
i figured out my mistake, .. i was using it wrong:

this is wrong.
PHP Code:
<?
$array
=shuffle($array);
?>
This is right.
PHP Code:
<?
shuffle
($array);
?>
sde is offline   Reply With Quote
Old 03-13-2003, 04:11 PM   #3 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
What arr you trying to do?

Ilya.
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 03-13-2003, 04:18 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
i was working on an online learning system .. for testing.

i needed to take a specific number of random questions from each cateogory of questions. within each category i needed to take 2 questions from each difficulty level.

then at the end i had a big array of question id's .. well even though i chose random questions from the database, they were still in order by category and difficulty level.

i needed an array function that would just mix up the array so the test could be given in random order.

shuffle() is a beatuiful thing. may levels of randomness in my program so chances are very very slim that a user retaking the test will get the same questions .. not to mention even slimmer that they get the same questions in the same order.

fun stuff =)
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 01:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 07:18 AM
Return an array with register_globals = off bdl PHP 7 03-10-2003 06:37 PM
Array of chars of chars of, wait, uh... anon Standard C, C++ 15 01-11-2003 05:15 PM
adding to an array in php sde PHP 1 06-12-2002 12:04 PM


All times are GMT -8. The time now is 01:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting