php function variable scope

I was wondering if i have a function like this:

function isAdmin ($user_id) {

    $admin_arr = array(1, 2);

    foreach ($admin_arr as $value) {

        if ($value == $user_id) {
            return true;
        }
    }

    return false;
}

Could i make an array outside of that function as a global array and use it inside the function without sending it through as a parameter, also instead declaring a new admin array inside the function as i just did above? How would i do this?

Regards, Alexander

5
задан Alexander 6 May 2011 в 13:20
поделиться