I have an array defined outside of a function. Both are inside of a file I include other places, and I use filterFunc(); on those other pages. In order for the function to run through the array, I need to define the array inside of it, as well. Unfortunately, I need to use the array elsewhere and don't feel like going through the globalizing thing. Here's what I have:
PHP Code:
$filterArr = array(
"all" => "All",
"sn" => "S/N",
"tags" => "Tags",
"vendor" => "Vendor",
"purdate" => "Pur Date",
"ticketnum" => "Ticket Num");
function filterFunc() {
$filterArr = array(
"all" => "All",
"sn" => "S/N",
"tags" => "Tags",
"vendor" => "Vendor",
"purdate" => "Pur Date",
"ticketnum" => "Ticket Num");
foreach($filterArr as $key => $val){
echo '<option value="'.$key.'">'.$val.'</option>'."\n";
}
}
Is there a reason why I can't just use $filterArr without redefining it inside of filterFunc();?
Bookmarks