$iconSet) { if (isset($iconSet['svgs']) && is_array($iconSet['svgs'])) { foreach ($iconSet['svgs'] as $svgIndex => $svg) { // Check if 'path' exists if (isset($svg['path'])) { // Extract the 'd' attribute value from the nested path string preg_match('/d=[\'"]([^\'"]+)[\'"]/i', $svg['path'], $matches); // If we found the 'd' value, format the paths correctly if (isset($matches[1])) { $dValue = $matches[1]; // Get the actual 'd' value from the path // Escape the 'd' value for JSON format (escape double quotes inside the string) $escapedDValue = str_replace('"', '\\"', $dValue); // Now, add the proper tag to the 'paths' field $svg['paths'] = ""; } unset($svg['path']); // Optionally remove the original 'path' key } // Save the modified svg back to the array $data[$index]['svgs'][$svgIndex] = $svg; } } } // Optional: Save the modified JSON to a new file $outputFile = 'solid-fixed-paths.json'; file_put_contents($outputFile, json_encode($data, JSON_PRETTY_PRINT)); // Output the success message echo "Successfully modified and saved the JSON file with 'path' converted to 'paths'.\n"; ?>