array_search_get_value() public static method

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
return string
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;
 }
 /**
  * Set all the names mapped to a single attribute from LDAP. This helps account for multiple mappings used for
  * different purposes.
  *
  * @param array $newEntry
  * @param string $attribute
  * @param array|string $value
  * @return mixed
  */
 protected function setMappedNames(array $newEntry, $attribute, $value)
 {
     // Get all names mapped to this LDAP attribute name...
     if (!$this->schema->hasNamesMappedToAttribute($attribute)) {
         return $newEntry;
     }
     $mappedNames = $this->schema->getNamesMappedToAttribute($attribute);
     foreach ($mappedNames as $mappedName) {
         // Any names specifically selected for should be in the result array...
         if ($this->selectedButNotPartOfEntry($mappedName, $newEntry)) {
             $newEntry[MBString::array_search_get_value($mappedName, $this->selectedAttributes)] = $value;
         }
     }
     return $newEntry;
 }