The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Call Array Value From Outside Function?
I'm working on a web-RPG, and need a little help with my database queries, as I need to be setting up globals using unfctions.
I'm using this simple code that I came up with after a few minutes of looking at the PHP manual (I've already set the database up): PHP Code:
The only problem is, I can only seem to call values from that array inside the function, meaning that this will work: PHP Code:
PHP Code:
|
#2
|
||||
|
||||
You could set up the user variable outside the function and pass it in to be filled or you could return the user variable. The way you have it set up now, its scope is only within the function.
|
#3
|
||||
|
||||
Quote:
|
#4
|
||||
|
||||
You can pass arrays in and out just like any other variable.
|
#5
|
||||
|
||||
Quote:
for instance, PHP Code:
|
#6
|
||||
|
||||
function test should have a return line in it that returns $var.
The code would look like: Code:
function test() { $var = "val"; return $var; } $othervar = test(); echo $othervar; |
#7
|
||||
|
||||
Thanks alot.
You rule. This will help me infinitely. As the English say, cheers! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|