I have a function with an array that has a lot of variables inside it that are declared outside of the function.
Here is a stripped down version of the function:
function get_badges(){
$badge_array = array(
array(
"Comment Freak",
($user_revision >= $revision_master_req) && ($tixx1 >= $tixx2)
),
array(
"Revision Freak",
($user_revisionx55 >= $revision_master_reqx134) && ($tixx11233 >= $tixx1342)
)
);
return $badge_array;
}
My question is, what would be the best way to access variables outside the function when considering performance? Upon research, I read I need to use globals but apparently that is not a good approach, particularly if I have many variables...
function get_badges($user_revision, $revision_master_req....)You may also consider grouping data into class objects or arrays, and passing just a few arguments instead.