Thread: array.random()
View Single Post
  #1  
Old 03-16-2011, 09:03 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
array.random()

Wouldn't mind seeing something like this:

PHP Code:
function onCreated() {
  
temp.arr = {
    
12345
  
};
  
temp.element temp.arr.random();
  echo(
temp.element); // Echos 1, 2, 3, 4, or 5

Same thing as doing...

PHP Code:
function onCreated() {
  
temp.arr = {
    
12345
  
};
  
temp.element arr[int(random(0arr.size()))];
  echo(
temp.element);

__________________
Quote:
Reply With Quote