Create a one-dimensional associative array from a list of objects, or a list of 2-tuples.

@param object[]|array $list
@param string $keyProperty
@param string $valueProperty
@return array
436765
public static function keyValue($list, $keyProperty=null, $valueProperty=null)
    {
        $index = array();
        foreach ($list as $i) {
            if ($keyProperty) {
                if (!$valueProperty) { 
                    throw new \InvalidArgumentException("Must set value property if setting key property");
                }
                $index[$i->$keyProperty] = $i->$valueProperty;
            }
            else {
                $key = current($i);
                next($i);
                $value = current($i);
                $index[$key] = $value;
            }
        }
        return $index;
    }
474001
private List<Object> toList(Class<?> valueType, Object arrayObject)
   {
      List<Object> defaultValues = new ArrayList<>();
      int length = Array.getLength(arrayObject);
      boolean isClassType = (valueType == Class.class);
      for (int i = 0; i < length; i++)
      {
         Object arrayValue = Array.get(arrayObject, i);
         if (isClassType)
         {
            arrayValue = ((Class<?>) arrayValue).getName();
         }
         defaultValues.add(arrayValue);
      }
      return defaultValues;
   }
554274
public function put($keyOrValue, $value = null, $keySource = null)
    {
        $key = $value === null ? null : $keyOrValue;
        $value = $value === null ? $keyOrValue : $value;

        $keySource = $keySource ?: $value;

        $key = $key ?: $this->key($keySource);
        $tags = $this->categorizer->tags($keySource);
        $lifetime = $this->categorizer->lifetime($keySource);

        $this->callBeforeListeners('put', [$this->storageName, $key, $value, $tags, $lifetime]);
        $this->storage->put($key, $value, $tags, $lifetime);
        $this->callAfterListeners('put', [$this->storageName, $key, $value, $tags, $lifetime]);

        return $this;
    }
424787
public function groupBy($list, $property, $meta=null)
    {
        if (!$list) {
            return [];
        }
        if (!$meta) {
            if (!($first = current($list))) {
                throw new \UnexpectedValueException();
            }
            $meta = $this->mapper->getMeta(get_class($first));
        }

        $groups = [];

        $props = $meta->getProperties();
        foreach ($list as $object) {
            $propDef = !isset($props[$property]) ? null : $props[$property];
            $value = !$propDef || !isset($propDef['getter']) 
                ? $object->{$property} 
                : call_user_func(array($object, $propDef['getter']));

            $groups[$value][] = $object;
        }
        return $groups;
    }
729005
protected static function createProperty(array $propertyValues)
    {
        return array_map(
            function($propertyValue) {
                if (is_array($propertyValue)) {
                    return isset($propertyValue['type']) ?
                        self::createItem($propertyValue) : self::tagLanguage($propertyValue);
                }

                return $propertyValue;
            },
            $propertyValues
        );
    }
212819
public function pluck($keyOfValue, $keyOfKey = null)
    {
        $results = [];
        foreach ($this->items as $item) {
            if (!is_array($item) && !($item instanceof ArrayAccess)) {
                if (is_object($item)) {
                    $item = [
                        $keyOfValue => isset($item->{$keyOfValue}) ? $item->{$keyOfValue} : null,
                        $keyOfKey => isset($item->{$keyOfKey}) ? $item->{$keyOfKey} : null,
                    ];
                }
                else {
                    $item = $this->getArrayableItems($item);
                }
            }
            if ($keyOfKey === null) {
                $results[] = isset($item[$keyOfValue]) ? $item[$keyOfValue] : null;
            }
            else {
                $results[isset($item[$keyOfKey]) ? $item[$keyOfKey] : null] = isset($item[$keyOfValue]) ? $item[$keyOfValue] : null;
            }
        }

        return new static($results);
    }
765713
public function readMap($keyType, $valueType) {
		$map = array();
		$count = $this->readShort();
		for ($i = 0; $i < $count; ++$i) {
			$map[$this->readByType($keyType, true)] = $this->readByType($valueType, true);
		}
		return $map;
	}
1363735
public function setItem($list, $k, $v)
    {
        $this->ensureArrayKeyIsArray($this, $list);

        $this[$list][$k] = $v;

        return $this;
    }
1001154
private static function addToResultArray(
        string $propertyName,
        $propertyValue,
        array $propertyNameMapper,
        array $resultArray
    ) {
        $mappedName = $propertyNameMapper[$propertyName]['name'] ?? $propertyNameMapper[$propertyName] ?? $propertyName;

        $resultArray[$mappedName] = self::isNestedData($propertyValue)
            ? self::toArray($propertyValue, $propertyNameMapper[$propertyName]['mapper'] ?? [])
            : $propertyValue;

        return $resultArray;
    }
968890
public function
	Append(Array $List, Bool $Keys=FALSE) {
	/*//
	goes through the given array and appends all the data to this dataset. by
	default the array keys are completely ignored. if you need to preseve
	the keys (and ergo overwrite any existing data) set the second argument
	to true.
	//*/

		foreach($List as $Key => $Value) {
			if(!$Keys)
			$this->Push($Value);

			else
			$this->Shove($Key,$Value);
		}

		return;
	}
871282
public function readList($valueType) {
		$list = array();
		$count = $this->readShort();
		for ($i = 0; $i < $count; ++$i) {
			$list[] = $this->readByType($valueType, true);
		}
		return $list;
	}
1355300
@Override
    public List<V> put(K key, List<V> valueList) {
        return listMap.put(key, valueList);
    }
343270
public function toKeyValue($keyGetter, $valueGetter)
    {
        $return = array();
        foreach ($this as $value) {
            if (!method_exists($value, $keyGetter)) {
                throw new MethodNotFoundException('Method ' . $keyGetter . ' not found on ' . get_class($value));
            }
            if (!method_exists($value, $valueGetter)) {
                throw new MethodNotFoundException('Method ' . $valueGetter . ' not found on ' . get_class($value));
            }
            $return[$value->$keyGetter()] = $value->$valueGetter();
        }

        return $return;
    }
791438
protected function recursiveAssignValue(array $values, $list)
	{
		//Loop through all the children and find out if one matches our value
		foreach ( $list as $item )
		{
			//Check if this is an option or group
			if ( $item instanceof Optgroup )
			{
				$this->recursiveAssignValue($values, $item->getContents());
			}

			//We have an option so check its value
			else if ( in_array($item->getValue(), $values) )
			{
				$this->assignSelected($item);
			}
		}
	}
334366
private function methodLoader(array $classProperties)
    {
        $result = [];
        foreach ($classProperties as $propertyName => $nullVal) {
            $result[$propertyName] = $this->getPropertyValue($propertyName);
        }

        return $result;
    }
1313220
public function setListByAssociativeArray($list) {
		
		foreach ($list as $value=>$text) {
				
			$option			= new \stdClass();
			$option->value	= $value;
			$option->text	= $text;
			$option->attributes	= [];

			$this->list[]	= $option;
				
		}
		
		return $this;
		
	}
22339
public function push($key, $value)
    {
        $array = $this->get($key, []);

        if(!is_array($array))
            throw new JsonPropertyException('Cannot push value to non array');

        array_push($array, $value);

        return $this->set($key, $array);
    }