View Single Post
  #6  
Old 06-11-2009, 05:45 AM
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
An array is pretty much just a string with comma's in it, so as long as you aren't doing crazy stuff this should get you by.

PHP Code:
function onCreated() {
  echo(
onTestFunc({"asdf""jkl;"})); // output = rawr
  
echo(onTestFunc({"rawr""asdf"})); // output = !
}
function 
onTestFunc(arr) {
  
temp.stuff = {
    {
"asdf""jklm"}, 123,
    {
"asdf""jkl."}, 124,
    {
"asdf""jkl;"}, "rawr"
  
};
  
arr arr.substring(0);
  for (
temp.0temp.stuff.size(); temp.+= 2) {
    if (
stuff[i].substring(0) == arr) return stuff[i+1];
  }
  return 
"!";

If the stuff array was properly sorted you could probably write a binary search instead of that simple for loop.
__________________
Quote:
Reply With Quote