public static function optimizeArray(array &$config, array &$cache = [])
	{
		foreach ($config as $k => &$v)
		{
			if (!is_array($v))
			{
				continue;
			}

			// Dig deeper into this array
			self::optimizeArray($v, $cache);

			// Look for a matching structure
			$cacheKey = serialize($v);
			if (!isset($cache[$cacheKey]))
			{
				// Record this value in the cache
				$cache[$cacheKey] = $v;
			}

			// Replace the entry in $config with a reference to the cached value
			$config[$k] =& $cache[$cacheKey];
		}
		unset($v);
	}
public static function optimizeArray(array &$config, array &$cache = [])
	{
		foreach ($config as $k => &$v)
		{
			if (!is_array($v))
			{
				continue;
			}

			// Dig deeper into this array
			self::optimizeArray($v, $cache);

			// Look for a matching structure
			$cacheKey = serialize($v);
			if (!isset($cache[$cacheKey]))
			{
				// Record this value in the cache
				$cache[$cacheKey] = $v;
			}

			// Replace the entry in $config with a reference to the cached value
			$config[$k] =& $cache[$cacheKey];
		}
		unset($v);
	}
public static function optimizeArray ( array & $ config , array & $ cache = [ ] ) { foreach ( $ config as $ k => & $ v ) { if ( ! is_array ( $ v ) ) { continue ; } // Dig deeper into this array self :: optimizeArray ( $ v , $ cache ) ; // Look for a matching structure $ cacheKey = serialize ( $ v ) ; if ( ! isset ( $ cache [ $ cacheKey ] ) ) { // Record this value in the cache $ cache [ $ cacheKey ] = $ v ; } // Replace the entry in $config with a reference to the cached value $ config [ $ k ] = & $ cache [ $ cacheKey ] ; } unset ( $ v ) ; }
Optimize the size of a deep array by deduplicating identical structures

This method is meant to be used on a config array which is only read and never modified

@param  array &$config
@param  array &$cache
@return array
Optimize the size of a deep array by deduplicating identical structures