@internal
Prepends associative element to the beginning of an array

@param array $arr The input array.
@param mixed $key The prepended key
@param mixed $val The prepended value

@return array The resulting array
347189
public static function array_unshift_assoc(&$arr, $key, $val)
    {
        $arr = array_reverse($arr, true);
        $arr[$key] = $val;
        $arr = array_reverse($arr, true);
        return $arr;
    }
871246
public static function getPrevKey($key, array $array) {
		$keys = array_keys($array);
		$found_index = array_search($key, $keys);
		if($found_index === false || $found_index === 0)
			return false;
		return $keys[$found_index - 1];
	}
521478
public function increment($key, $val = 1)
    {
        return apc_inc($this->conf['prefix'] . $key, abs(intval($val)));
    }
1144920
public function setDefaultData($key, $val = null)
    {
        if(is_array($key))
        {
            foreach($key as $k=>$v)
            {
                $this->setDefaultData($k, $v);
            }
        }
        else
        {
            $this->defaultData[$key] = $val;
        }

        return $this;
    }
1252980
public function prepend($value, $key = null): Arrayy
    {
        $this->checkTypeWrapper($value);

        return parent::prepend($value, $key);
    }
1287282
public static function pick( $key, $arr ) 
	{	
		if( !is_array( $arr ) ) 
		{
			throw new \InvalidArgumentException('CCArr::pick - second argument has to be an array.');
		}

		$return = array();

		foreach( $arr as $array ) 
		{
			$return[] = CCArr::get( $key, $array );
		}

		return $return;
	}
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;
    }
680430
protected function custom($key, $val)
    {
        $extra = [
            'value' => (isset($val['name'])) ? $val['name'] : $key,
        ];

        return $this->composeElement($key, $val, $extra);
    }
187376
public static function setdefault(&$arr, $key, $value) {
    isset($arr[$key]) or $arr[$key] = $value;
  }
1323949
protected function arrayTable($arr, array $header = [ 'Key', 'Value' ])
    {

        $rows = [ ];
        foreach ($arr as $key => $val) {
            if (is_array($val)) {
                $val = print_r(array_slice($val, 0, 5), true);
            }
            $rows[] = [ (string)$key, (string)$val ];
        }
        $this->table($header, $rows);
    }
1323712
public static function remove(&$arr, $key, $default = null)
    {
        if (isset($arr[$key])) {
            $value = $arr[$key];
            unset($arr[$key]);
        } else {
            $value = $default;
        }

        return $value;
    }
621335
static function getArray($arr,$key,$default=array())
    {
        $value = Utility::get($arr, $key);
        return ($value!=null)?explode(',', $value):$default;
    }
1118455
public static function pick(array &$arr, $key)
    {
        if (\array_key_exists($key, $arr)) {
            $value = $arr[$key];
            unset($arr[$key]);

            return $value;
        }

        return null;
    }
598544
public function sortArrayByColumn(&$arr, $col)
    {
        $newArray = [];
        $sort_col = array();
        foreach ($arr as $key => $row) {
            $sort_col[$key] = strtoupper($row[$col]);
        }
        asort($sort_col, SORT_LOCALE_STRING);

        foreach ($sort_col as $key => $val) {
            $newArray[$key] = $arr[$key];
        }

        $arr = $newArray;
    }
1209777
public static function _arrayToObjects ($arr, $key = FALSE)
	{
		
		// Set object array
		
		$objs	=  new Resource\Model\Collection;
		
		// If no data

		if (!$arr)
		{
			return $objs;
		}
		
		// For each row
		
		foreach ($arr as $row)
		{

			// Create the object

			$obj	= new static;

			// Set each attribute value

			foreach ($row as $name => $val)
			{

				if ($obj->attributeExists ($name))
				{
					$obj->iset ($name, $val, FALSE, TRUE);
				}

			}
			
			// Add to the array
			
			if ($key && isset ($row[$key]))
			{
				$objs[$row[$key]]	= $obj;
			}
			else
			{
				$objs[]	= $obj;
			}

		}
		
		// Return the objects
		
		return $objs;
		
	}
1308375
private function parseKeys(array $arr) {
        $output = $this->getArrayValue();
        $append_regex = '/\s*\+\s*$/';
        foreach ($arr as $k => $v) {
            if (is_array($v) && FALSE === strpos($k, '.')) {
                // this element represents a section; recursively parse the value
                $output[$k] = $this->parseKeys($v);
            } else {
                // if the key ends in a +, it means we should append to the previous value, if applicable
                $append = false;
                if (preg_match($append_regex, $k)) {
                    $k = preg_replace($append_regex, '', $k);
                    $append = true;
                }

                // transform "a.b.c = x" into $output[a][b][c] = x
                $current = & $output;

                $path = $this->property_nesting ? explode('.', $k) : array($k);
                while (($current_key = array_shift($path)) !== null) {
                    if ('string' === gettype($current)) {
                        $current = array($current);
                    }

                    if (!array_key_exists($current_key, $current)) {
                        if (!empty($path)) {
                            $current[$current_key] = $this->getArrayValue();
                        } else {
                            $current[$current_key] = null;
                        }
                    }
                    $current = & $current[$current_key];
                }

                // parse value
                $value = $v;
                if (!is_array($v)) {
                  $value = $this->parseValue($v);
                }

                if ($append && $current !== null) {
                    if (is_array($value)) {
                        if (!is_array($current)) {
                            throw new LogicException("Cannot append array to inherited value '{$k}'");
                        }
                        $value = array_merge($current, $value);
                    } else {
                        $value = $current . $value;
                    }
                }

                $current = $value;
            }
        }

        return $output;
    }
1317638
public static function arrayGroup($arr, $key){
        $result = [];
        foreach($arr as $k=>$v){
            $result[$v[$key]][] = $v;
        }
        return $result;
    }