Can you directly access an array from a public static function in PHP?

When accessing an array from a public static function in PHP, you can do so by passing the array as a parameter to the function. This allows the function to directly access and manipulate the array without needing to declare it as a global variable. By passing the array as a parameter, you maintain better control over the function's dependencies and improve the function's reusability.

<?php
class ArrayManipulator {
    public static function manipulateArray($array) {
        // Perform operations on the $array parameter
        $array[] = "new element";
        return $array;
    }
}

// Example of how to use the static function
$inputArray = [1, 2, 3];
$outputArray = ArrayManipulator::manipulateArray($inputArray);
print_r($outputArray);
?>