/** * Recursively convert the provided array to a string, suitable for storage on disk * * @param string $RootCacheKey if not null, the name of the key fr this iteration * @param array $Cache cache data * @param ref $CacheStr reference to the destination string * @param int $FormatIndentLevel depth of indentation for pretty data files * @return string innards of cache data array */ public static function RecurseArrayStr($RootCacheKey, $Cache, &$CacheStr, $FormatIndentLevel = 0) { if ($RootCacheKey !== NULL) { $CacheStr .= str_repeat(' ', $FormatIndentLevel) . "'{$RootCacheKey}' => "; } if (is_array($Cache)) { $CacheStr .= "array(\n"; } $First = TRUE; foreach ($Cache as $CacheKey => $CacheValue) { if (!$First) { $CacheStr .= ",\n"; } if ($First) { $First = FALSE; } if (!is_array($CacheValue)) { $CacheStr .= str_repeat(' ', $FormatIndentLevel + 1); if (!is_numeric($CacheKey)) { $CacheStr .= "'{$CacheKey}' => "; } $CacheStr .= "'{$CacheValue}'"; } else { Gdn_LibraryMap::RecurseArrayStr($CacheKey, $CacheValue, $CacheStr, $FormatIndentLevel + 1); } } if (is_array($Cache)) { $CacheStr .= "\n" . str_repeat(' ', $FormatIndentLevel) . ")"; } }