Skip to content

Instantly share code, notes, and snippets.

@icco
Created February 19, 2009 08:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icco/66792 to your computer and use it in GitHub Desktop.
Save icco/66792 to your computer and use it in GitHub Desktop.
[gist: ####] formatting with PHP
<?php
// Gist replacement inspired by http://github.com/guitsaru/code-feather/
if(preg_match("/\[gist: ([0-9]+)\]/i", $out, $matches)) {
return '<script src="http://gist.github.com/'.$matches[1].'.js"></script>';
}
// Can also be done in one line.
$out = preg_replace("/\[gist: ([0-9]+)\]/i", '<script src="http://gist.github.com/\\1.js"></script>', $out);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment