Page 1 of 1

Array help, please

Posted: Mon Feb 28, 2005 1:00 pm
by Name-Less
I'm currently in the process of designing my first online-game (Good vs. Evil).

I'm currently writing the code for the function which will calculate the life/magic/stat changes when an attack is made, spell cast, etc. Well, I'm wanting it to return all the stats in an array.

Is there any way to do this?

If you don't understand, this is how I'm hoping to code it.

Code: Select all

function battle_system_function(arg1, arg2, etc . . . ) {
//
//  All calculations take place here
//
return array_here;
}

arrayї] = battle_system_function;
I realize that syntax probably isn't correct; but, that's the format I want to use. Can anyone offer a solution or help for this? Thanks.

Name-Less,
Administrator of GvE

Posted: Mon Feb 28, 2005 1:01 pm
by feyd

Code: Select all

return array('foo','bar');

Posted: Mon Feb 28, 2005 1:05 pm
by Weirdan

Code: Select all

function something($arg1, $arg2, $arg3 /*....etc....*/) {
  $ret = array();
  $retї'something'] = 'blah';
  $retї'something else'] = 36 / 24 + $arg3;
  $retї12] = __FILE__;
  
  // and so on...

  return $ret;
}

$data = something(1, 'asd', 543);
var_dump($data);

Posted: Mon Feb 28, 2005 1:08 pm
by Name-Less
Alright, thank you both for the help.