Usage

Syntax: array.remove(string);

Explanation

Searches for the string in the array. If found, it will be deleted from the array.

Example

function onCreated()
{
  temp.foo = {"foo", "foo", "baz", "bar"};
  temp.foo.remove("foo");
  temp.foo.remove("bar");
}

... Will set temp.foo to {"foo", "baz"}, since we've remove 1 "foo" and 1 "bar" from the array. Note that it will not remove all indexes of the string, it will delete the first one it finds and stop there. If you want to delete all traces of a string in an array, you can do so easily by using a while loop:

function onCreated()
{
  temp.foo = {"foo", "foo", "baz", "bar", "foo"};

  while("foo" in temp.foo)
	temp.foo.remove("foo");
  
  echo(temp.foo);
}

... Which would echo "baz,bar" since all instances of "foo" is removed. Basicly what it does is that the loop keeps on going until there's no more instances of "foo" in the array.

Categories

CategoryObjectFunction
CategoryFunctionClientside
CategoryFunctionServerside

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki