php global arrays

W

wes

How do i make an array in php a global array? The code:
$employee_array[0] = "Bob";
display();
function display(){
echo $employee_array[0];
}
....Does not print Bob.
I have tried:
function display(){
global $employee_array[0];
echo $employee_array[0];
}
....still doesnt work. Please help
Thanks Wes
 
J

Jim Moe

wes said:
How do i make an array in php a global array? The code:
I have tried:
function display(){
global $employee_array[0];
echo $employee_array[0];
}
...still doesnt work. Please help
Do not add the [] operator:
global $employee_array;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top