<?php
$message = "This is a string using the terms? Wait here's one\n abukuma kai\nabukuma-kai\nabukuma\nabukuma\nkai abukuma abukuma kai";
$search = array(
'abukuma kai',
'abukuma'
);
$replacements = array(
// here all replaces | each in a new line - watch the syntax
// all html possible, but no single quotation mark!
'<a href="http://kancolle.wikia.com/wiki/Abukuma#Upgrade" class="screenshot" rel="ship/Abukuma_Kai.png" style="color:#0073e6; font-weight:bold; border-bottom: 1px #0073e6 dashed;"><p id="yosup">Abukuma Kai</p></a>',
'<a href="http://kancolle.wikia.com/wiki/Abukuma#Basic" class="screenshot" rel="ship/Abukuma.png" style="color:#0073e6; font-weight:bold; border-bottom: 1px #0073e6 dashed;">Abukuma</a>'
);
// Massage the message
$message = preg_replace(
array_map(
function($s) {
$s = preg_quote($s);
$s = str_replace(' ', '[ -_]', $s);
return '/' . $s . '/';
},
$search
),
array_map(
function ($s) {
return '%%' . $s . '%%';
},
array_keys($search)
),
$message
);
$message = str_replace(
array_map(
function($s) {
return '%%' . $s . '%%';
},
array_keys($replacements)
),
$replacements,
$message
);
var_dump($message);
preferences:
36.84 ms | 402 KiB | 5 Q