Diverse array with a specific value

@param  [type] $array [description]
@return array [type]        [description]
328788
public static function array_diverse($array)
    {
        $result = array();

        foreach ($array as $key1 => $value1) {
            if (is_array($value1)) {
                foreach ($value1 as $key2 => $value2) {
                    $result[$key2][$key1] = $value2;
                }
            } else {
                $result[0][$key1] = $value1;
            }
        }

        return $result;
    }
615820
public function expandArray($array)
    {
        $retval = "";
        for ($i = 0; $i < count($array); $i++) {
            $retval .= $this->expandString($array[$i]);
        }

        return $retval;
    }
570472
private function filterUniqueRole($array)
    {
        $arrayRewrite = array();
        foreach ($array as $key => $parent)
        {
            foreach ($parent as $role)
            {
                if (!isset($arrayRewrite[$key]) || !in_array($role, $arrayRewrite[$key]))
                {
                    $arrayRewrite[$key][] = $role;
                }
            }
        }
        return $arrayRewrite;
    }
1220548
private function decodeArray($array) {

        $return_value = array();

        foreach ( $array->data->value as $value ) {

            $return_value[] = $this->decodeValue($value);

        }

        return $return_value;

    }
596005
public static function flatten(array $array)
    {
        $result = array();

        array_walk_recursive($array, function ($value, $key) use (& $result) {
            if (is_numeric($key) or is_object($value)) {
                $result[] = $value;
            } else {
                $result[$key] = $value;
            }
        });

        return $result;
    }
81745
protected function sanitizeArray($array)
    {
        foreach($array as $key => $value){
            if(is_array($value)){
                $array[$key] = $this->sanitizeArray($value);
            } else {
                $array[$key] = $this->convertStaticPhpExcelConstantsFromStringsToConstants($value);
            }
        }

        return $array;
    }
952847
public function stdClassToArrayCheckValues(array $array)
    {
        foreach ($array as $key => $value) {
            if ($value instanceof \stdClass) {
                $array[ $key ] = $this->stdClassToArray($value);
            } else if (is_array($value)) {
                $array[ $key ] = $this->stdClassToArrayCheckValues($value);
            } else {
                $array[ $key ] = $value;
            }
        }

        return $array;
    }
1012481
static public function sortByKeyRecursive(array $array)
    {
        ksort($array);
        foreach ($array as $key => $value) {
            if (is_array($value) && !empty($value)) {
                $array[$key] = self::sortByKeyRecursive($value);
            }
        }

        return $array;
    }
1254829
public static function sortRecursive($array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                $value = static::sortRecursive($value);
            }
        }

        if (static::isAssoc($array)) {
            ksort($array);
        } else {
            sort($array);
        }

        return $array;
    }
1163230
public function insertAll($array)
    {
        $ids = array();
        foreach ($array as $hash) {
            $ids[] = $this->del('set')->set($hash)->insert();
        }

        return $ids;
    }
934802
public static function array_flip2( $array )
	{
		$result = array();
		foreach ( $array as $key => $value )
		{
			if ( isset( $result[ $value ] ) && in_array( $key, $result[ $value ] ) ) continue;
			$result[ $value ][] = $key;
		}
		return $result;
	}
162994
public static function flat(array $array)
    {
        $out = [];
        foreach ($array as $key=>$value) {
            if (is_array($value)) {
                //use recursion to get to the next array
                $out = array_merge($out, self::flat($value));
            } else {
                //add the value to the back of the array
                //if the value is not an array
                $out[] = $value;
            }
        }
        //return the resulting array
        return $out;
    }
770556
public static function arrayUnique(array $array)
    {
        // Serialize each array's value
        foreach ($array as &$value) {
            $value = serialize($value);
        }

        // Now remove duplicate strings
        $array = array_unique($array);

        // Now restore to its previous state with removed strings
        foreach ($array as &$value) {
            $value = unserialize($value);
        }

        return $array;
    }
920431
private function trimArray($array)
    {
        foreach ($array as $key => $value) {
            // Do not attemp to trim array variables, boolean variables, or the proxy password
            // Trimming a boolean value (as a string) may not produce the expected output, so pass it through as-is
            if (!is_array($value) && !is_bool($value) && $key !== 'proxy_password') {
                $array[$key] = trim($value);
            }
        }
        return $array;
    }
1300364
protected function arrayToTable(array $array)
    {
        list($keys, $values) = array_divide($array);

        return collect($keys)->zip(collect($values))->toArray();
    }
337076
public static function array_flatten(array $array){
		$index = 0;
		$count = count($array);

		while ($index < $count) {
			if (is_array($array[$index])) {
				array_splice($array, $index, 1, $array[$index]);
			} else {
				++$index;
			}
			$count = count($array);
		}
		return $array;
	}
945027
protected function getArrayType(array $array) {
		$indices = count(array_filter(array_keys($array), 'is_string'));

		if ($indices == 0) {
			$type = self::ARRAY_TYPE_LIST;
		} elseif ($indices == count($array)) {
			$type = self::ARRAY_TYPE_DICT;
		} else {
			$type = self::ARRAY_TYPE_MIXED;
		}

		return $type;
	}