Possible Duplicate:
PHP global variable not found in functions
I have a function that reads data from a database. I have an array that I want to put data from the database into for easier manipulation. I define my array outside the function and populate it when the function is called.
$rid = "";
if(isset($_GET['rid'])){
$rid = $_GET['rid'];
}
$dates = array();
function getData($rid){
//Db Connection Strings
//Query stuff etc
//DATES
for ($i=0; $i < 5; $i++) {
$mil = (float)$query->table->records->record->f[$i];
$seconds = $mil / 1000;
$dt = gmdate('m-d-Y', $seconds);
$dates[$i] = $dt;
}
print_r($dates);//THIS WORKS
}
getData($rid);
print_r($dates);//THIS DOESN'T
My issue is: Unless I call refer to $dates within the function, it will not spit out my data. I need to have this done outside the function so I can put the values into text fields at run time.
How do I get my values into my $dates array so they can be used globally? Thanks!