实例
<?php $str = "Hello world! æøå"; echo $str . "<br>"; echo convert_cyr_string($str,'w','a'); ?>
定义和用法
convert_cyr_string() 函数把字符串由一种 Cyrillic 字符集转换成另一种。
被支持的 Cyrillic 字符集是:
k - koi8-r
w - windows-1251
立即学习“PHP免费学习笔记(深入)”;
i - iso8859-5
a - x-cp866
d - x-cp866
m - x-mac-cyrillic
注释:该函数是二进制安全的。
语法
convert_cyr_string(string,from,to)
参数 描述
string 必需。规定要转换的字符串。
from 必需。一个规定了源 Cyrillic 字符集的字符。
to 必需。一个规定了目标 Cyrillic 字符集的字符。
技术细节
返回值: 返回已转换的字符串。
PHP 版本: 4+
convert_cyr_string实例
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
PHP 代码:
<?php
$xml = simplexml_load_file("test.xml");
foreach ($xml->children() as $child)
{
echo "Child node: " . $child;
}
?>输出类似:
Child node: George Child node: John Child node: Reminder Child node: Don't forget the meeting!
以上就是php把字符串由一种字符转换成另一种的函数convert_cyr_string() 的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号