Yes, possible with array_count_values. Is this what you are looking for?
The function array_count_values() will count the number of unique values in the array. If you get the count of it to be 1, it is then unique like you said.
count(array_count_values($myArray)) == 1
Also, you can check one of the array values to be whatever value you wanted to check.
$myArray[0] == "S"
So combining these two in a single condition:
count(array_count_values($myArray)) == 1 && $myArray[0] == "S"
This will return true or false.
Full Working Code
<?php
// Let's have two arrays.
$myArray1 = array("S", "S", "S"); // Should return true
$myArray2 = array("S", "S", "s"); // Should return false
// Our function
function checkArray($theArray, $value) {
return count(array_count_values($myArray)) == 1 && $myArray[0] == $value;
}
// Checks
checkArray($myArray1, "S"); // true
checkArray($myArray2, "s"); // false
array_count_values. Is this what you are looking for?