Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/LookupRef.php
public static function MATCH($lookupValue, $lookupArray, $matchType = 1)
    {
        $lookupArray = Functions::flattenArray($lookupArray);
        $lookupValue = Functions::flattenSingleValue($lookupValue);
        $matchType = ($matchType === null) ? 1 : (int) Functions::flattenSingleValue($matchType);

        // MATCH is not case sensitive
        $lookupValue = strtolower($lookupValue);

        // Lookup_value type has to be number, text, or logical values
        if ((!is_numeric($lookupValue)) && (!is_string($lookupValue)) && (!is_bool($lookupValue))) {
            return Functions::NA();
        }

        // Match_type is 0, 1 or -1
        if (($matchType !== 0) && ($matchType !== -1) && ($matchType !== 1)) {
            return Functions::NA();
        }

        // Lookup_array should not be empty
        $lookupArraySize = count($lookupArray);
        if ($lookupArraySize <= 0) {
            return Functions::NA();
        }

        // Lookup_array should contain only number, text, or logical values, or empty (null) cells
        foreach ($lookupArray as $i => $lookupArrayValue) {
            //    check the type of the value
            if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
                (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
            ) {
                return Functions::NA();
            }
            // Convert strings to lowercase for case-insensitive testing
            if (is_string($lookupArrayValue)) {
                $lookupArray[$i] = strtolower($lookupArrayValue);
            }
            if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) {
                $lookupArray = array_slice($lookupArray, 0, $i - 1);
            }
        }

        if ($matchType == 1) {
            // If match_type is 1 the list has to be processed from last to first

            $lookupArray = array_reverse($lookupArray);
            $keySet = array_reverse(array_keys($lookupArray));
        }

        // **
        // find the match
        // **

        if ($matchType == 0 || $matchType == 1) {
            foreach ($lookupArray as $i => $lookupArrayValue) {
                if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) {
                    //    exact match
                    return ++$i;
                } elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) {
                    $i = array_search($i, $keySet);

                    // The current value is the (first) match
                    return $i + 1;
                }
            }
        } else {
            // matchType = -1

            // "Special" case: since the array it's supposed to be ordered in descending order, the
            // Excel algorithm gives up immediately if the first element is smaller than the searched value
            if ($lookupArray[0] < $lookupValue) {
                return Functions::NA();
            }

            $maxValueKey = null;

            // The basic algorithm is:
            // Iterate and keep the highest match until the next element is smaller than the searched value.
            // Return immediately if perfect match is found
            foreach ($lookupArray as $i => $lookupArrayValue) {
                if ($lookupArrayValue == $lookupValue) {
                    // Another "special" case. If a perfect match is found,
                    // the algorithm gives up immediately
                    return $i + 1;
                } elseif ($lookupArrayValue >= $lookupValue) {
                    $maxValueKey = $i + 1;
                }
            }

            if ($maxValueKey !== null) {
                return $maxValueKey;
            }
        }

        // Unsuccessful in finding a match, return #N/A error value
        return Functions::NA();
    }
public static function MATCH($lookupValue, $lookupArray, $matchType = 1)
    {
        $lookupArray = Functions::flattenArray($lookupArray);
        $lookupValue = Functions::flattenSingleValue($lookupValue);
        $matchType = ($matchType === null) ? 1 : (int) Functions::flattenSingleValue($matchType);

        // MATCH is not case sensitive
        $lookupValue = strtolower($lookupValue);

        // Lookup_value type has to be number, text, or logical values
        if ((!is_numeric($lookupValue)) && (!is_string($lookupValue)) && (!is_bool($lookupValue))) {
            return Functions::NA();
        }

        // Match_type is 0, 1 or -1
        if (($matchType !== 0) && ($matchType !== -1) && ($matchType !== 1)) {
            return Functions::NA();
        }

        // Lookup_array should not be empty
        $lookupArraySize = count($lookupArray);
        if ($lookupArraySize <= 0) {
            return Functions::NA();
        }

        // Lookup_array should contain only number, text, or logical values, or empty (null) cells
        foreach ($lookupArray as $i => $lookupArrayValue) {
            //    check the type of the value
            if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
                (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
            ) {
                return Functions::NA();
            }
            // Convert strings to lowercase for case-insensitive testing
            if (is_string($lookupArrayValue)) {
                $lookupArray[$i] = strtolower($lookupArrayValue);
            }
            if (($lookupArrayValue === null) && (($matchType == 1) || ($matchType == -1))) {
                $lookupArray = array_slice($lookupArray, 0, $i - 1);
            }
        }

        if ($matchType == 1) {
            // If match_type is 1 the list has to be processed from last to first

            $lookupArray = array_reverse($lookupArray);
            $keySet = array_reverse(array_keys($lookupArray));
        }

        // **
        // find the match
        // **

        if ($matchType == 0 || $matchType == 1) {
            foreach ($lookupArray as $i => $lookupArrayValue) {
                if (($matchType == 0) && ($lookupArrayValue == $lookupValue)) {
                    //    exact match
                    return ++$i;
                } elseif (($matchType == 1) && ($lookupArrayValue <= $lookupValue)) {
                    $i = array_search($i, $keySet);

                    // The current value is the (first) match
                    return $i + 1;
                }
            }
        } else {
            // matchType = -1

            // "Special" case: since the array it's supposed to be ordered in descending order, the
            // Excel algorithm gives up immediately if the first element is smaller than the searched value
            if ($lookupArray[0] < $lookupValue) {
                return Functions::NA();
            }

            $maxValueKey = null;

            // The basic algorithm is:
            // Iterate and keep the highest match until the next element is smaller than the searched value.
            // Return immediately if perfect match is found
            foreach ($lookupArray as $i => $lookupArrayValue) {
                if ($lookupArrayValue == $lookupValue) {
                    // Another "special" case. If a perfect match is found,
                    // the algorithm gives up immediately
                    return $i + 1;
                } elseif ($lookupArrayValue >= $lookupValue) {
                    $maxValueKey = $i + 1;
                }
            }

            if ($maxValueKey !== null) {
                return $maxValueKey;
            }
        }

        // Unsuccessful in finding a match, return #N/A error value
        return Functions::NA();
    }
MATCH.

The MATCH function searches for a specified item in a range of cells

Excel Function:
=MATCH(lookup_value, lookup_array, [match_type])

@param mixed $lookupValue The value that you want to match in lookup_array
@param mixed $lookupArray The range of cells being searched
@param mixed $matchType The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.

@return int The relative position of the found item