Skip to content

Instantly share code, notes, and snippets.

@madeinnordeste
Created May 3, 2014 01:02
Show Gist options
  • Save madeinnordeste/0c6f8ae744460d39a79b to your computer and use it in GitHub Desktop.
Save madeinnordeste/0c6f8ae744460d39a79b to your computer and use it in GitHub Desktop.
PHP - Move Script TAGS to bottom
<?php
$source = file_get_contents("http://www.mywebsite.com");
preg_match_all("/<script(.|\n)*?<\/script>/", $source, $matches);
$source = preg_replace("/<script(.|\n)*?<\/script>/", '', $source);
$scripts = implode('', $matches[0]);
$source = preg_replace("/<\/body>/", $scripts.'</body>', $source);
echo $source;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment