字符串函数
<?php
// mb_substr返回中文字符串的一部分
echo mb_substr("你好朋友", 0, 2);
// 输出:你好
?><hr>
<!-- 把字符串中的首字符转换为大写。 -->
<?php
echo ucfirst("hello world!");
?> <hr>
<!-- 把字符串中每个单词的首字符转换为大写 -->
<?php
echo ucwords("hello world");
?> <hr>
<!-- 把字符串单词替换成文字 -->
<?php
$arr = array("Hello" => "你好", "world" => "朋友");
echo strtr("Hello world",$arr);
?><hr>
<!-- 反转字符串 -->
<?php
echo strrev("1234567");
?>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!