My code is:
$db = &JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('old', 'new')))
->from($db->quoteName('#__words'));
$db->setQuery($query);
$results = $db->loadAssocList();
$find = array();
$replace = array();
foreach ($results as $row) {
$find[] = $row['old'];
$replace[] = $row['new'];
}
$newstring = str_replace($find, $replace, $oldstring);
echo $newstring;
This code replaces all words from the "old" column with words from the "new" column. But there are two problems. At first it works if the found and replaced words have the same case (upper or lower), but I need it to work regardless of case, i.e. The database has only lower case, but if the search word on the external interface has upper case, the replaced word should also have capital letters. Secondly, I need an exact word match. Thank you in advance!
source
share