Array help, please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Array help, please

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

return array('foo','bar');
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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);
Name-Less
Forum Newbie
Posts: 7
Joined: Mon Nov 15, 2004 8:26 am
Location: Missouri
Contact:

Post by Name-Less »

Alright, thank you both for the help.
Post Reply