LdapTools\Utilities\MBString::array_search_get_value PHP Метод

array_search_get_value() публичный статический Метод

Given an array value determine if it exists in the array and return the value as it is in the array.
public static array_search_get_value ( string $needle, array $haystack ) : string
$needle string
$haystack array
Результат string
    public static function array_search_get_value($needle, array $haystack)
    {
        $lcNeedle = self::strtolower($needle);
        foreach ($haystack as $value) {
            if ($lcNeedle == self::strtolower($value)) {
                return $value;
            }
        }
        throw new InvalidArgumentException(sprintf('Value "%s" not found in array.', $needle));
    }

Usage Example

Пример #1
0
 /**
  * This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name,
  * such as for sorting arrays.
  * 
  * @param $selected
  * @param $aliases
  * @return array
  */
 protected function getFormattedOrderBy($selected, $aliases)
 {
     if (!empty($aliases) && !$this->isWildCardSelection()) {
         $orderBy = [];
         foreach ($this->orderBy as $attribute => $direction) {
             list($alias, $attr) = LdapUtilities::getAliasAndAttribute($attribute);
             $orderAttr = MBString::array_search_get_value($attr, $selected);
             $orderAttr = $alias ? "{$alias}.{$orderAttr}" : $orderAttr;
             $orderBy[$orderAttr] = $direction;
         }
     } else {
         $orderBy = $this->orderBy;
     }
     return $orderBy;
 }
All Usage Examples Of LdapTools\Utilities\MBString::array_search_get_value