tags with href attribute for CSS files
$pattern = '/]*?\srel=["\']?stylesheet["\'].*?\shref=["\']?\/(.*?)["\'][^>]*?>/i';
// Use preg_replace_callback to replace matched link tags with inline styles
$outputString = preg_replace_callback($pattern, function($match) {
// Extract the href attribute value
$href = $match[1];
$fname = $_SERVER['DOCUMENT_ROOT'] . '/' . $href;
echo "from $fname";
// Get the content of the local CSS file
$cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href);
// Replace url() declarations in the CSS content with updated paths
$cssContent = preg_replace_callback('/url\(["\']?\/(.*?)(?:[?#].*?)?["\']?\)/i', function($urlMatch) {
// Extract the URL value
$url = $urlMatch[1];
// Modify the path as needed
$modifiedPath = '/new/path/' . $url;
// Create the updated url() declaration
$updatedUrlDeclaration = 'url("' . $modifiedPath . '")';
return $updatedUrlDeclaration;
}, $cssContent);
// Create an inline style tag with the modified CSS content
return "";
}, $inputString);
return $outputString;
}
function inlineScriptFromSrc($inputString) {
// Define the regular expression pattern to match ";
}, $inputString);
return $outputString;
}