Converts an array where the key and value should be mapped to a nested array
@param {array} $array Source Array
@param {string} $keyLbl Array's Key mapping name
@param {string} $valueLbl Key's value mapping name
@return {array} Unmapped array
331955
final protected function arrayUnmap($array, $keyLbl='id', $valueLbl='title') {
        $result=array();
        
        foreach($array as $key=>$value) {
            $result[]=array(
                            $keyLbl=>$key,
                            $valueLbl=>$value
                        );
        }
        
        
        //Return the resulting array
        return $result;
    }
1163740
public static function createFromArray(?array $array): ?BinarySearchTree {
        if (null === $array) {
            return null;
        }
        $tree = new BinarySearchTree();
        if (0 === \count($array)) {
            return $tree;
        }
        foreach ($array as $element) {
            if (null === $element) {
                continue;
            }
            $tree->insertValue($element);
        }
        return $tree;
    }
866077
public static function map(array $array, callable $callback)
    {
        $newArray = [];

        foreach ($array as $key => $item) {
            $result = $callback($item, $key);

            $newArray = is_array($result) ?
                array_replace_recursive($array, $result) :
                array_merge_recursive($array, (array) $result);
        }

        return $newArray;
    }
1363717
public static function groupElementsByValueKeys($array, $groupKeys) {

        if (!is_array($groupKeys)) {
            $groupKeys = array($groupKeys);
        }

        $newArray = new AssociativeArray();
        foreach ($array as $element) {

            $applyObject = $newArray;
            foreach ($groupKeys as $index => $groupKey) {
                if ($index < sizeof($groupKeys) - 1) {
                    $subArray = $applyObject[$element[$groupKeys[$index]]];
                    if (!$subArray) {
                        $subArray = new AssociativeArray();
                        $applyObject[$element[$groupKeys[$index]]] = $subArray;
                    }
                    $applyObject = $subArray;
                } else {
                    if (!is_array($applyObject[$element[$groupKeys[$index]]])) {
                        $applyObject[$element[$groupKeys[$index]]] = array();
                    }
                    $applyObject[$element[$groupKeys[$index]]][] = $element;

                }
            }

        }

        
        return $newArray->toArray();
    }
296603
public final function map($where, $valueField, $keyField = null, $rows = []) {
        $sql = $this->select($valueField, $keyField);
        $sql->where($where);
        $rst = $sql->toArray($valueField, $keyField, $rows);
        $this->checkSQL($sql);

        return $rst;
    }
499527
public function key_search( array $array, $key, $value ) {
		foreach ( $array as $key => $a ) {
			if ( isset( $a[ $key ] ) && $a[ $key ] == $value ) {
				return $key;
			}
		}

		return false;
	}
329473
public static function reindex(array $array, array $map, bool $unmapped = true): array
    {
        $reindexed = $unmapped
            ? $array
            : [];

        foreach ($map as $from => $to) {
            if (isset($array[$from])) {
                $reindexed[$to] = $array[$from];
            }
        }

        return $reindexed;
    }
859773
private function buildMap(ServiceLocatorInterface $sl, array $array)
    {
        $map = new Map();
        foreach ($array as $format => $visitorName) {
            $visitor = $visitorName;
            if (is_string($visitorName)) {
                if ($sl->has($visitorName)) {
                    $visitor = $sl->get($visitorName);
                } elseif (class_exists($visitorName)) {
                    $visitor = new $visitorName();
                }
            }

            if ($visitor instanceof VisitorInterface) {
                $map->set($format, $visitor);
                continue;
            }

            throw new InvalidArgumentException(sprintf(
                'Invalid (de-)serialization visitor"%s" given, must be a service name, '
                    . 'class name or an instance implementing JMS\Serializer\VisitorInterface',
                is_object($visitorName)
                    ? get_class($visitorName)
                    : (is_string($visitorName) ? $visitorName : gettype($visitor))
            ));
        }

        return $map;
    }
1313613
public static function pluck($array, string $key, $defaultValue = null): array
    {
        $result = [];
        if (!is_array($array)) {
            return $result;
        }

        // Extract key/path.
        $keyLast = Str::last($key, '.');
        $key = Str::removeLast($key, '.');

        // Extract data.
        if ($key !== '' && $key !== null) {
            $array = self::dataByPath($array, $key, false, []);
        }
        foreach ($array as $item) {
            $value = $defaultValue;
            if (is_object($item) && isset($item->{$keyLast})) {
                $value = $item->{$keyLast};
            } elseif (is_array($item) && isset($item[$keyLast])) {
                $value = $item[$keyLast];
            }
            $result[] = $value;
        }

        return $result;
    }
680481
public static function convertStringToValueArray(array $array): array
    {

        foreach ($array as $i => $attr)
            $array[$i] = (is_array($attr) ? self::convertStringToValueArray($attr) : self::convertStringToValues($attr));

        return $array;
    }
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;
	}
892943
public static function arrayPluck($array, $key)
    {
        return array_map(function($value) use ($key) {
            return is_object($value) ? $value->$key : $value[$key];
        }, $array);
    }
293126
public static function keyFlattening($array, $keys = []) {
		if (is_array($array)) {
			$result = [];
			foreach ($array as $key => $value) {
				$tmp_keys = $keys;
				$tmp_keys [] = $key;
				$result = array_merge($result, static::keyFlattening($value,$tmp_keys));
			}
			return $result;
		}

		$key = array_shift($keys);
		return [
			empty($keys) ? $key : sprintf('%s[%s]', $key, implode ('][', $keys)) => $array,
		];
	}
444431
public function reverseTransform($valueAsArray)
    {
        if (empty($valueAsArray)) {
            $valueAsArray = [];
        }
        if (!is_array($valueAsArray)) {
            $valueAsArray = [$valueAsArray];
        }
        return serialize($valueAsArray);
    }
842060
static protected function normalizeArrayValues($key, array $valueList)
    {
        $normalized = '';
        $equal = $key . '=';
        foreach ($valueList as $value) {
            $normalized .= (empty($normalized) ? '' : '&') . $equal . urlencode($value);
        }

        return $normalized;
    }
751355
public static function set(array &$array, $keyPath, $value)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));
        $result = $array;
        $ptr = &$result;

        $parentKeys = array();
        while ($keys !== array()) {
            $key = array_shift($keys);
            $parentKeys[] = $key;

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = $keys === array() ? $value : array();
                $ptr = &$ptr[$key];
                continue;
            }
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                $ptr = $value;
                break;
            }
            elseif (!is_array($ptr)) {
                throw new InconsistentKeyTypes($ptr, array(), implode('.', $parentKeys));
            }
        }

        $array = $result;
    }
146354
public function array_map( $array, $callback ) {
		$array = $this->get_array_value( $array );

		return array_map( function ( $d ) use ( $callback ) {
			return is_callable( $callback ) ? $callback( $d ) : ( is_string( $callback ) && method_exists( $d, $callback ) ? $d->$callback() : null );
		}, $array );
	}