php global arrays

Discussion in 'HTML' started by wes, Mar 9, 2006.

  1. wes

    wes Guest

    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
     
    wes, Mar 9, 2006
    #1
    1. Advertising

  2. wes

    Jim Moe Guest

    wes wrote:
    > 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;

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
     
    Jim Moe, Mar 9, 2006
    #2
    1. Advertising

  3. wes

    wes Guest

    Works perfect Jim!
    Thanks
     
    wes, Mar 9, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ted Zeng
    Replies:
    4
    Views:
    515
    Tim Arnold
    Oct 3, 2006
  2. Ted Zeng
    Replies:
    0
    Views:
    638
    Ted Zeng
    Oct 13, 2006
  3. torque63
    Replies:
    0
    Views:
    626
    torque63
    Jan 1, 2009
  4. Philipp
    Replies:
    21
    Views:
    1,134
    Philipp
    Jan 20, 2009
  5. Rajive Narain
    Replies:
    0
    Views:
    1,895
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page