Loads the options from an associative array

@param array $arr Associative array of options
@param mixed $values (optional) Array or comma delimited string of selected values
@return PEAR_Error|bool on error or true
@throws PEAR_Error
357227
function loadArrayOptGroups($arr, $values=null)
    {
        if (!is_array($arr)) {
            return self::raiseError('Argument 1 of HTML_Select::loadArrayOptGroups is not a valid array');
        }
        if (isset($values)) {
            $this->setSelected($values);
        }
        foreach ($arr as $key => $val) {
            // Warning: new API since release 2.3
            $this->addOptGroup($key, $val);
        }
        return true;
    }
316674
protected function add(array $values)
    {
        $values =
            $this->dispatchBeforeOperationEvent(
                '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\BeforeBlockAddingEvent',
                BlockEvents::BEFORE_ADD_BLOCK,
                $values,
                'exception_block_adding_aborted'
            );

        $this->validator->checkEmptyParams($values);
        $requiredParameters = array("PageId" => "", "LanguageId" => "", "SlotName" => "");
        $this->validator->checkRequiredParamsExists($requiredParameters, $values);

        // When the Content is null the dafault text is inserted
        if (!array_key_exists('Content', $values)) {
            $defaults = $this->getDefaultValue();
            if (!is_array($defaults)) {
                $exception = array(
                    'message' => 'exception_method_returns_invalid_value',
                    'parameters' => array(
                        '%className%' => get_class($this),
                    ),
                );
                throw new General\InvalidArgumentTypeException(json_encode($exception));
            }

            $mergedValues = array_merge($values, $defaults);
            $availableOptions = array(
                'Content' => '',
                'InternalJavascript' => '',
                'ExternalJavascript' => '',
                'InternalStylesheet' => '',
                'ExternalStylesheet' => '',
            );
            $this->validator->checkOnceValidParamExists($availableOptions, $mergedValues);
            $values = $mergedValues;
        }

        try {
            $this->blockRepository->startTransaction();

            // Saves the content
            if (null === $this->alBlock) {
                $className = $this->blockRepository->getRepositoryObjectClassName();
                $this->alBlock = new $className();
            }

            $values = $this->checkCreatedAt($values);
            $result = $this->blockRepository
                    ->setRepositoryObject($this->alBlock)
                    ->save($values);
            if (false !== $result) {
                $this->blockRepository->commit();
                $this->eventsHandler
                     ->createEvent(BlockEvents::AFTER_ADD_BLOCK, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\AfterBlockAddedEvent', array($this))
                     ->dispatch();

                return $result;
            }

            $this->blockRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            if (isset($this->blockRepository) && $this->blockRepository !== null) {
                $this->blockRepository->rollBack();
            }

            throw $e;
        }
    }
1029385
function InListFromValues(array $values)
    {
        if (count($values) == 0)
        {
            return null;
        }
        $list = $this->InList($this->Value($values[0]));
        foreach ($values as $value)
        {
            $list->Add($this->Value($value));
        }
        return $list;
    }
1173756
public static function object( $arr ) 
	{
		if( !is_array( $arr ) ) 
		{
			throw new \InvalidArgumentException("CCArr::object - only arrays can be passed.");
		}

		$object = new \stdClass();

		if ( !empty( $arr ) ) 
		{
			foreach ( $arr as $name => $value) 
			{
				if ( is_array( $value ) ) 
				{
					$value = static::object( $value );
				}
				$object->$name = $value;
			}
		}

		return $object;
	}
732930
public function setSelected(array $values)
	{
		$this->assertMultiSelect();

		$candidates = array();
		/* @var $candidates SelectOption[] */

		foreach ( $this->getOptions() as $option ) {
			if ( in_array($option->getValue(), $values) ) {
				$candidates[] = $option;
			}
		}

		return $this->selectOptions($candidates);
	}
1028113
public function fromArray(array $arr)
    {
        foreach ($arr as $key => $value) {
            $method = 'set' . $key;
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }
742539
public function addValues($values=array()) {
		return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);});
	}
1269918
private static function array_filter($arr, $values, $inverse = false)
    {
        if (!is_array($values)) {
            $values = explode(',', $values);
        }

        $result = array();
        $keep   = array_flip((array)$values);

        foreach ($arr as $key => $val) {
            if ($inverse != isset($keep[strtolower($val)])) {
                $result[$key] = $val;
            }
        }

        return $result;
    }
92890
public static function defaults(array $arr = null, array $defaults): array
    {
        if ($arr === null) {
            return $defaults;
        }
        foreach ($defaults as $key => $value) {
            if (!isset($arr[$key])) {
                $arr[$key] = $value;
            }
        }
        return $arr;
    }
279261
public function loadChoicesForValues(array $values, $value = null)
    {
        @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED);

        // Optimize
        $values = array_filter($values);
        if (empty($values)) {
            return [];
        }

        return $this->loadChoiceList($value)->getChoicesForValues($values);
    }
910418
public function tryGetOptionsForValues(array $values): array
    {
        $optionsIndexedByHash = [];

        foreach ($this->getAll() as $option) {
            $optionsIndexedByHash[ValueHasher::hash($option->getValue())] = $option;
        }

        $options = [];

        foreach ($values as $value) {
            $hash = ValueHasher::hash($value);

            if (isset($optionsIndexedByHash[$hash])) {
                $options[] = $optionsIndexedByHash[$hash];
            }
        }

        return $options;
    }
484094
public static function fromArray(array $values)
    {
        $bucket = isset($values['bucket']) ? $values['bucket'] : null;
        $key    = isset($values['key']) ? $values['key'] : null;
        $tag    = isset($values['tag']) ? $values['tag'] : null;

        return new RiakLink($bucket, $key, $tag);
    }
116778
public static function arrMergeAll(array &$arr, $arr2)
    {
        if (is_array($arr2)) {
            foreach ($arr2 as $key => $val) {
                $arr[$key] = $val;
            }
        } else {
            $arr[] = $arr2;
        }

        return $arr;
    }
1317715
public static function Deserialize($arr){
		if(is_null($arr))
			return null;
		$res=Array();
		$i=-1;
		$len=sizeof($arr);
		while(++$i<$len)
			$res[$arr[$i]->Key]=$arr[$i]->Value;
		return $res;
	}
1176340
public function filterNullValuesFromArray(array $arr): array
    {
        foreach ($arr as $key => $value) {
            if ($value === null) {
                unset($arr[$key]);
            }
            if (is_array($value)) {
                $arr[$key] = $this->filterNullValuesFromArray($value);
            }
        }

        return $arr;
    }
321252
public function setOptionArray(array $arr) {
        foreach($arr as $option => $value) {
            CurlOptions::checkOptionValue($option, $value);
        }

        return curl_setopt_array($this->handle, $arr);
    }
67255
public function setDefinedValues(array $values)
    {
        foreach ($this->_definition as $key => $value) {
            $this->setOptionalValueInArray($key, $values);

            if (!array_key_exists($key, $values)) {
                throw new Exception ('Value is missing for "' . $key . '"');
            }

            $this->$key = $values[$key];
        }

        return $this;
    }