I am trying to pass a few arrays to one of the functions w/in a class I've written, and it's doing something very strange. Here's the block of my code where I define my arrays as global:
function buildFormAndTable($global_arrays, $additional_constraints) {
if($global_arrays != NULL) {
echo "array_count: ".count($global_arrays)."<br />\n";
while($array = each($global_arrays)) {
global ${$array["key"]};
}
print_r($GLOBALS);
}
if($additional_constraints != NULL) {
while($each = each($additional_constraints)) {
$more_constraints[$each["key"]] = $each["value"];
}
}
And here is how I'm defining and then passing the variables:
$global_arrays["item_priority_array"] = $item_priority_array;
$global_arrays["extra_manage_variable"] = $item_priority_array;
$global_arrays["item_category_array"] = $item_category_array;
$global_arrays["item_status_array"] = $item_status_array;
print_r($global_arrays);
reset($global_arrays);
$additional_constraints["search_project_id"]= $_POST["search_project_id"];
$additional_constraints["search_task_id"]= $_POST["search_task_id"];
$additional_constraints["search_status"]= $_POST["search_status"];
$additional_constraints["search_item_category"]= $_POST["search_item_category"];
$listing_table -> buildFormAndTable($global_arrays, $additional_constraints);
From the print_r in the above command, I'm getting these results:
Array
(
[item_priority_array] => Array
(
[1] => Low
[2] => Medium
[3] => High
)
[extra_manage_variable] => Array
(
[1] => Low
[2] => Medium
[3] => High
)
[item_category_array] => Array
(
[bug] => Bugs
[feature] => Features
)
[item_status_array] => Array
(
[1] => Open
[2] => On Hold
[3] => Closed
)
)
But when I pass these through the function, and then look at the results of the print_r($GLOBALS) statement, I get this:
...
[global_arrays] => Array
(
[item_priority_array] => Array
(
[1] => Low
[2] => Medium
[3] => High
)
[extra_manage_variable] => Array
(
[1] => Low
[2] => Medium
[3] => High
)
[item_category_array] => Array
(
[bug] => Bugs
[feature] => Features
)
[item_status_array] => Array
(
[1] => Open
[2] => On Hold
[3] => Closed
)
)
[additional_constraints] => Array
(
[search_project_id] => 1
[search_task_id] =>
[search_status] =>
[search_item_category] => bug
)
[extra_manage_variable] =>
)
I can't for the life of me figure out why that "extra_manage_variable" is hanging out there on the end. If I eliminate that as one of the arrays that I pass to the function, everything works just fine. I moved the $global_arrays["extra_manage_variable"] = $item_priority_array; to the top of that list, to the bottom... wherever, it's still giving me the extra array 'spot' at the end.
I have different data that I would like to pass in that array, and I thought maybe my data was the problem. But I dont' see any reason why that last [extra_manage_variable] => is there at the end of my list of global vals.
Any ideas?