how to convert this block of code into a php version

  <script>

// Javascript program to check if all array elements are
// same or not.

function areSame(arr)
{
    // Put all array elements in a HashSet
    let s = new Set(arr);

    // If all elements are same, size of
    // HashSet should be 1. As HashSet contains only distinct values.
    return (s.size == 1);
}
 
// Driver code
let arr=[1, 2, 3, 2];
if (areSame(arr))
        document.write("All Elements are Same");
    else
        document.write("Not all Elements are Same");

// This code is contributed by patel2127