View Single Post
  #7  
Old 01-08-2011, 08:38 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
Quote:
Originally Posted by callimuc View Post
uhm usually idk how to use arrays... is there any easy example i can look up or does the wiki have it? (pretty sure they hae )
Posted not too long ago.

Quote:
Originally Posted by fowlplay4 View Post
Here's my quick run-through on Arrays which are useful in managing Collections or Lists of values.

Arrays

PHP Code:
function onCreated() {

  
// Creating an Array
  
this.array = {123};

  
// Reading from an Array (Reading Element in Position 1)
  // Syntax: this.array[element_index]
  // Arrays are 0-based so in our example:
  // this.array[0] is 1
  // this.array[1] is 2
  // this.array[2] is 3
  
temp.element this.array[1];
  echo(
"Element: " temp.element);

  
// Changing a Specific Element in an Array
  
this.array[2] = 3.14;
  
display_array();

  
// Adding to an Array
  
this.array.add(4);
  
display_array();

  
// Removing from an Array
  
this.array.remove(1);
  
display_array();

  
// Inserting into an Array (Inserts 2.5 into Position 1)
  
this.array.insert(12.5);
  
display_array();

  
// Deleting from an Array (Deletes Element in Position 1);
  
this.array.delete(1);
  
display_array();

  
// Combining Arrays
  
temp.newarray = {567};
  
this.array.addarray(temp.newarray);
  
display_array();

  
// Getting the Size / Number of Elements in Array
  
temp.elements this.array.size();
  echo(
"Array contains " temp.elements " elements!");
}

function 
display_array() {
  echo(
"Array: " this.array);

__________________
Quote:
Reply With Quote