こんにちは私は彼らのgreec類似した表情で文字を変更するための簡単な機能を、それはすべてのテキストを変更するには大丈夫だ、このHTML文字列のコードpreg_replace_callbackは、すべてのHTML文字列に適用されていません
function homographit($string){
$alphabet = array("A", "B", "C", "E", "H", "J", "K", "M", "N", "O", "P", "S", "T", "X", "Y",
"a", "b", "c", "e", "i", "j", "k", "o", "p", "r", "s", "v", "x", "y");
$Greec = array("\u0391", "\u0392", "\u0421", "\u0395", "\u0397", "\u0408", "\u039A", "\u039C", "\u039D", "\u039F", "\u03A1", "\u0405",
"\u03A4", "\u03A7", "\u03A5", "\u0430", "\u042C", "\u0441", "\u0435", "\u0456", "\u0458", "\u03BA", "\u03BF", "\u03C1", "\u0433", "\u0455",
"\u03BD", "\u03C7", "\u0443");
$newstring = str_replace($alphabet, $Greec, $string);
return json_decode('"'.$newstring.'"', true);
}
$html = '<html><h1> some text i want to replace</h1><p>some stuff i want to replace </p>';
$text_to_echo = preg_replace_callback(
"/(<([^.]+)>)([^<]+)(<\\/\\2>)/s",
function($matches){
$text= homographit($matches[3]);
return $matches[1].$text.$matches[4];
},
$html
);
echo $text_to_echo;
を.here編集した:
$html = '<html><h1> some text i want to replace</h1><p>some stuff i want to replace </p>';
しかし、私はこの1つを変更した場合:
$html = '<html> <body> <p> Lina has <span>blue</span>eyes and my bruno has <span>dark green </span> eyes</p></body></html>';
私fucntionのhomographitはAですテキストのパーティーにpplied。
html文字列の任意のテキストに変更を適用するためにpreg_replace_callbackのパターンを変更するnhelp?あなたは、フォーム<tag>some text</tag>
の完全なHTMLタグが一致しないために正規表現を変更することができます
THX
BIG THANKS Progman –