Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4343847 to your computer and use it in GitHub Desktop.
Save anonymous/4343847 to your computer and use it in GitHub Desktop.
Convert ticket IDs (Redmine => GitHub)
<?php
$arrMap = array(1=>17, 34=>98);
$strBody = '
Nina Gerling said On Thu, Dec 30. 2010
I\'d recomment using the headline like I recommended in ticket #326:
my comment on this, also watch out on #34
';
$strBody = preg_replace_callback('/#([0-9]+)/', 'replaceTickets', $strBody);
function replaceTickets($matches)
{
global $arrMap;
if (isset($arrMap[$matches[1]]))
{
return '#'.$arrMap[$matches[1]];
}
else
{
return 'http://www.contao-forge.org/issues/'.$matches[1];
}
}
var_dump($strBody);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment