$maxNesting) return false; foreach ($segments as $segment) if (!self::validateName($segment)) return false; return true; } /** * Formats an INI file string from an array * @param array $data Data to format. * @param int $level Specifies the level of array value. * @return string Returns the INI file string. */ public static function formatIniString($data, $level = 1) { $content = null; $sections = []; foreach ($data as $key=>$value) { if (is_array($value)) { if ($level == 1) $sections[$key] = self::formatIniString($value, $level+1); else { foreach ($value as $val) $content .= $key.'[] = "'.$val.'"'.PHP_EOL; } } elseif (strlen($value)) $content .= $key.' = "'.$value.'"'.PHP_EOL; } foreach ($sections as $key=>$section) $content .= PHP_EOL.'['.$key.']'.PHP_EOL.$section.PHP_EOL; return trim($content); } }