php从右向左反转电子邮件
我有电子邮件:ue.aporue。lraporue@otlatnom-德拉塔·恩霍伊 我希望它像: 约翰·阿塔德-montalto@europarl.europa.eu 当我使用revue.aporue这个词时。lraporue@otlatnom-德拉塔·恩霍伊;我得到: 欧盟,欧罗巴。europarl@montalto-阿塔德·约翰php从右向左反转电子邮件,php,string,reverse,Php,String,Reverse,我有电子邮件:ue.aporue。lraporue@otlatnom-德拉塔·恩霍伊 我希望它像: 约翰·阿塔德-montalto@europarl.europa.eu 当我使用revue.aporue这个词时。lraporue@otlatnom-德拉塔·恩霍伊;我得到: 欧盟,欧罗巴。europarl@montalto-阿塔德·约翰 function revWords($string) { //We need to find word boundries $wordChars
function revWords($string) {
//We need to find word boundries
$wordChars = 'abcdefghijklmnopqrstuvwxyz';
$buffer = '';
$return = '';
$len = strlen($string);
$i = 0;
while ($i < $len) {
$chr = $string[$i];
if (($chr & 0xC0) == 0xC0) {
//UTF8 Characer!
if (($chr & 0xF0) == 0xF0) {
//4 Byte Sequence
$chr .= substr($string, $i + 1, 3);
$i += 3;
} elseif (($chr & 0xE0) == 0xE0) {
//3 Byte Sequence
$chr .= substr($string, $i + 1, 2);
$i += 2;
} else {
//2 Byte Sequence
$i++;
$chr .= $string[$i];
}
}
if (stripos($wordChars, $chr) !== false) {
$buffer = $chr . $buffer;
} else {
$return .= $buffer . $chr;
$buffer = '';
}
$i++;
}
return $return . $buffer;
}
有人能帮我吗谢谢为什么不行
PHP有一个内置函数来反转字符串: 使用有什么问题
//strrev ( string $string )
echo strrev('ue.aporue.lraporue@otlatnom-dratta.nhoj');
//Returns john.attard-montalto@europarl.europa.eu
现在我明白了为什么求职面试中经常会出现反串任务
//strrev ( string $string )
echo strrev('ue.aporue.lraporue@otlatnom-dratta.nhoj');
//Returns john.attard-montalto@europarl.europa.eu