MathPHP\Statistics\Average::splitAtValue PHP Method

splitAtValue() private static method

Given an array and a value, separate the array into two groups, those values which are greater than the value, and those that are less than the value. Also, tell how many times the value appears in the array.
private static splitAtValue ( array $numbers, integer $value ) : array
$numbers array
$value integer
return array
    private static function splitAtValue(array $numbers, $value) : array
    {
        $lower = [];
        $upper = [];
        $number_equal = 0;
        foreach ($numbers as $number) {
            if ($number < $value) {
                $lower[] = $number;
            } elseif ($number > $value) {
                $upper[] = $number;
            } else {
                $number_equal++;
            }
        }
        return ['lower' => $lower, 'upper' => $upper, 'equal' => $number_equal];
    }