On Tuesday 31 December 2002 21:44, Martin S wrote: > > But something like: > > > > echo setCurrentDevGroup($devID); > > That gives the correct value as well. But I wanted it as a variable > ($lookuptable) ... > > What I am trying to do is: > > setCurrentDevGroup($this->Computer); // call function and get a device > group switch ($lookuptable) { > case "computers": > bla bla bla > case "printers": > yada yada yada > } > > However, getting the inspired moment from your post, I tried > > switch (setCurrentDevGroup($this->Computer)) { > case "computers": > bla bla bla > case "printers": > yada yada yada > } > > And now this part works at least. > My understanding was that the function would return a value for > $lookuptable which was useable in the code above. This is incorrect then?
If you want it so that the value of $lookuptable (in the global scope) is changed when you call your function then you have to do something like: <?php function doo($dah, $dee, $etc) { global $lookuptable; $lookuptable = "Hello world"; } doo(1, 2, 3); echo $lookuptable; // prints "Hello world" ?> More examples in manual > Variables > Variable scope -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* It's faster horses, Younger women, Older whiskey and More money. -- Tom T. Hall, "The Secret of Life" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php