...

View Full Version : Array Values in function



ptmuldoon
05-10-2008, 04:44 PM
I think I need to rethink one of my scripts, and turn it into more of a common function that can be used in various places. In doing so, I was wondering if its possibly to use an array to include all the necessary variables needed.

I was thinking for example that I could query a row from a table, with all its values in an array.

Then to use the array values when calling the function. An example of something like below. Would the array values have to return the same fields name all the time? Or is something like this not possible?



$values = array('player','color','gid','gname');

function game_log($values)
{
$player = $values['player'];

blah, blah, blah, rest of function
}

Inigoesdr
05-10-2008, 05:13 PM
Would the array values have to return the same fields name all the time?
Not necessarily, but you would probably want them to. If you selected the fields from the database the array would look more like this, though:

$array = array('player' => 'ptmuldoon', 'color' => 'blue', 'gid' => 1, 'gname' => 'ptmuldoon');



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum