So i have php function that was written for php 5.6. I think this was the source originally when i put it together. I made a few changes. This is the code i ended up with:
function Format($input){
//escape input
$search = array(
'/\[b\](.*?)\[\/b]/is',
'/\[i\](.*?)\[\/i]/is',
'/\[u\](.*?)\[\/u]/is',
'/\[s\](.*?)\[\/s]/is',
'/\[img\](.*?)\[\/img\]/is',
'/\[color=(.*?)\](.*?)\[\/color\]/is',
'/\[quote=(.*?)\]/e',
'/\[p\](.*?)\[\/p]/is',
);
$replace = array(
'<b>$1</b>',
'<i>$1</i>',
'<u>$1</u>',
'<s>$1</s>',
'<img src="$1">',
'<font style="color:$1;">$2</font>',
'GenerateQuote($1)',
'<a style="color:#ff6600" href=https://' . $_SERVER['SERVER_NAME'] .'/(...)/$1>$1</a>'
);
return preg_replace($search, $replace, $input);
}
function GenerateQuote($commentID){
$sqlresult = mysqli_query($db, "(...)");
(...)
return $QuoteCode;
}
The function is used to convert BB tags in a piece of text to the corrosponding HTML tags. The quote tag used an /e argument that is not supported anymore in PHP 7.
preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Can someone help me migrate this piece of code from PHP 5.6 to PHP 7? I can't figure out how to do it.