Skip to content

Instantly share code, notes, and snippets.

@aschempp
Forked from anonymous/gist:4343847
Created December 20, 2012 08:41
Show Gist options
  • Save aschempp/4343854 to your computer and use it in GitHub Desktop.
Save aschempp/4343854 to your computer and use it in GitHub Desktop.
<?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, but do not convert @#6 but
#1 should be';
$strBody = preg_replace_callback('/([\n| ])#([0-9]+)/', 'replaceTickets', $strBody);
function replaceTickets($matches)
{
global $arrMap;
if (isset($arrMap[$matches[2]]))
{
return $matches[1].'#'.$arrMap[$matches[2]];
}
else
{
return $matches[1].'http://www.contao-forge.org/issues/'.$matches[2];
}
}
var_dump($strBody);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment