PHP 中将一个字符转换为另一个字符
我有两个数组,一个包含假日语字符,另一个包含英文字母 我不知道从这里到哪里去,我尝试过循环、str_replace,甚至使用字母数组作为 jap 数组的键,该数组确实适用于一个单词,但我想分解单词并在包含时转换它们的空间。
$name = $_POST['engname'];
$name = strtoupper($name);
$jap = array('ka','tu','mi', 'te','ku', 'lu', 'ji', 'ri', 'ki', 'zu', 'me', 'ta', 'rin', 'to', 'mo', 'no', 'ke', 'shi', 'ari', 'chi', 'do', 'ru', 'mei', 'na', 'fu', 'zi');
$letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$names = explode(' ',$name);
$letters = array();
foreach($name as $names) {
$names[] = join('<br/>', str_split($names));
}
echo join('<br/>',$names);
I have two arrays one with fake Japanese characters, another with the English alphabet
I have no idea where to go from here, I've tried loops, str_replace, even using the letters array as the keys for the jap array which did work for one word, but I want to break up the words and convert them while including the space.
$name = $_POST['engname'];
$name = strtoupper($name);
$jap = array('ka','tu','mi', 'te','ku', 'lu', 'ji', 'ri', 'ki', 'zu', 'me', 'ta', 'rin', 'to', 'mo', 'no', 'ke', 'shi', 'ari', 'chi', 'do', 'ru', 'mei', 'na', 'fu', 'zi');
$letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$names = explode(' ',$name);
$letters = array();
foreach($name as $names) {
$names[] = join('<br/>', str_split($names));
}
echo join('<br/>',$names);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHP 有一个函数:
strtr
(不确定您想要朝哪个方向走,JAP->ENG 或 ENG->JAP,但从您使用
strtoupper
的事实来看,我认为是后者)PHP has a function for that:
strtr
(Not sure in which direction you want to go, JAP->ENG or ENG->JAP but from the fact that you use
strtoupper
I assume the latter)