global array declaration

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
nst
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Feb 13, 2006 7:51 am

Wed Jun 14, 2006 6:16 am

I have an array $delete_entry[]

I want to take some values from a function and use them in another function.
The variables inside the new function would be of the type
$delete_entry[$id]

I am using globals in order to do this like
global $id;
etc.

What's the appropriate global declaration for the array?

User avatar
Redcircle
Moderator
Moderator
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Wed Jun 14, 2006 7:57 pm

$GLOBALS['delete_entry'] = $delete_entry;


$GLOBALS is a superglobal and can be access throughout the entire scope.

you my just want to pass the array as a parameter

Code: Select all

function a(){
    $foo = 'bar'
    b($foo);
}

function b($foo){
    echo $foo; //echo's 'bar'
}

Post Reply