
Originally Posted by
alex weber
!!!!!!!!!!!!!!!!!!!!!
I'm not sure what you mean by that, but if you want to know why you "can't just use it," then I'll tell you: PHP is designed like that on purpose. Variables (arrays, functions, etc.) in one scope (say, outside a function) are invisible to those in another (say, inside that function). As frustrating as that may be at times, it's in place for a good reason: it prevents accidental conflicts (like accidentally overwriting an important variable when executing an outside function that happens to have a variable with the same name). If you want to know more, read here.
It's too bad you "don't feel like going through the globalizing thing," because that's basically the only way to get around redefining the variable inside your function (or passing it in through the function call).
But it's not that hard.
As djr said,
PHP Code:
<?php
$filterArr = array(
"all" => "All",
"sn" => "S/N",
"tags" => "Tags",
"vendor" => "Vendor",
"purdate" => "Pur Date",
"ticketnum" => "Ticket Num"
);
function filterFunc() {
// this is basically Example #1 from the php.net link I gave above
global $filterArr;
foreach($filterArr as $key => $val){
echo '<option value="'.$key.'">'.$val.'</option>'."\n";
}
}
?>
Edit:
also, you seem to have a bunch of random hyperlinks in your last post. What gives?
Bookmarks