尝试有趣的事情。这样的作品。当我将此脚本附加到文本字段并要求他们翻译事物时, 我的朋友会喜欢它。我认为您可以做任何事情。毛皮。我检查了几次代码, 如果我想使用它, 它可以工作, 但是我对所有这些都不熟悉。我认为距开始学习php已经两三周了。
$html = ('
Dear so and so, after reviewing your application I. . .
More of the same...
sincerely,
Important Dude
$oldWords = array('important', 'sincerely');
$newWords = array('arrogant', 'ya sure');
// function for oldWords
function regex_oldWords_word_list(&$item1, $key)
{
$item1 = "/>([^<>]+)?\b$item1(tionally|istic|tion|ance|ence|less|ally|able|ness|ing|ity|ful|ant|est|ist|ic|al|ed|er|et|ly|y|s|d|'s|'d|'ve|'ll)?\b([^<>]+)?/";
}
// function for newWords
function format_newWords_results(&$item1, $key)
{
$item1 = ">$1 $item1$2$3";
}
// apply regex to oldWords
array_walk($oldWords, 'regex_oldWords_word_list');
// apply formatting to newWords
array_walk($newWords, 'format_newWords_results');
//HTML is not always as perfect as we want it
$poo = array('/ /', '/>([a-zA-Z\']+)/', '/’/', '/;([a-zA-Z\']+)/', '/"([a-zA-Z\']+)/', '/([a-zA-Z\']+)', '/\.\.+/', '/\. \.+/');
$unpoo = array(' ', '> $1', '\'', '; $1', '" $1', '$1
//and maybe things will go back to normal sort of
$repoo = array('/> /', '/; /', '/" /', '/ ');
$muck = array('> ', ';', '"','
//before
echo ($html);
//I don't know what was happening on the free host but I had to keep stripping slashes
//This is where the work is done anyway.
$html = stripslashes(preg_replace($repoo , $muck , (ucwords(preg_replace($oldWords , $newWords , (preg_replace($poo , $unpoo , (stripslashes(strtolower(stripslashes($html)))))))))));
//after
echo ('
' . $html);
//now if only there were a way to keep it out of the area between
// and here and tell it that english isn't math.
?>