24 public static function lookup($lookupValue, $lookupArray, $indexNumber, $notExactMatch =
true)
31 $indexNumber = self::validateIndexLookup($lookupArray, $indexNumber);
33 return $e->getMessage();
36 $f = array_keys($lookupArray);
37 $firstRow = reset(
$f);
38 if ((!is_array($lookupArray[$firstRow])) || ($indexNumber > count($lookupArray))) {
42 $firstkey =
$f[0] - 1;
43 $returnColumn = $firstkey + $indexNumber;
44 $firstColumn = array_shift(
$f);
45 $rowNumber = self::hLookupSearch($lookupValue, $lookupArray, $firstColumn, $notExactMatch);
47 if ($rowNumber !== null) {
49 return $lookupArray[$returnColumn][$rowNumber];
55 private static function hLookupSearch($lookupValue, $lookupArray, $column, $notExactMatch)
60 foreach ($lookupArray[$column] as $rowKey => $rowData) {
62 $bothNumeric = is_numeric($lookupValue) && is_numeric($rowData);
63 $bothNotNumeric = !is_numeric($lookupValue) && !is_numeric($rowData);
68 (($bothNumeric && $rowData > $lookupValue) || ($bothNotNumeric && $cellDataLower > $lookupLower))
73 $rowNumber = self::checkMatch(
static hLookupSearch($lookupValue, $lookupArray, $column, $notExactMatch)
static strToLower($pValue)
Convert a UTF-8 encoded string to lower case.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static lookup($lookupValue, $lookupArray, $indexNumber, $notExactMatch=true)
HLOOKUP The HLOOKUP function searches for value in the top-most row of lookup_array and returns the v...