小白教程
所有教程
关于
Search
172.70.131.29
172.70.131.29
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func string ltrim”的源代码
本页内容
上一节:
Func_string_localeconv
下一节:
Func_string_md5
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:ltrim()}}[[分类:PHP字符串函数参考手册|29]] = PHP ltrim() 函数 = [[:分类:PHP字符串函数参考手册]] 移除字符串左侧的字符: <sample title="" desc="" lang="php" hererun="1"> <?php $str = "Hello World!"; echo $str . "<br>"; echo ltrim($str,"Hello"); ?> </sample> == 定义和用法 == ltrim() 函数移除字符串左侧的空白字符或其他预定义字符。 相关函数: * [[func string rtrim|rtrim()]] - 移除字符串右侧的空白字符或其他预定义字符。 * [[func string trim|trim()]] - 移除字符串两侧的空白字符或其他预定义字符。 == 语法 == <pre> ltrim(string,charlist) </pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | string | 必需。规定要检查的字符串。 |- | charlist | 可选。规定从字符串中删除哪些字符。如果省略该参数,则移除下列所有字符: * "\0" - NULL * "\t" - 制表符 * "\n" - 换行 * "\x0B" - 垂直制表符 * "\r" - 回车 * " " - 空格 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回已修改的字符串。 |- | PHP 版本: | 4+ |- | 更新日志: | 在 PHP 4.1 中,新增了 charlist 参数。 |} == 更多实例 == == 实例 1 == 移除字符串左侧的空格: <sample title="" desc="" lang="php" hererun="1"> <?php $str = " Hello World!"; echo "Without ltrim: " . $str; echo "<br>"; echo "With ltrim: " . ltrim($str); ?> </sample> 上面代码的 HTML 输出如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> <!DOCTYPE html> <html> <body> Without ltrim: Hello World!<br>With ltrim: Hello World! </body> </html> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> Without ltrim: Hello World! With ltrim: Hello World! </sample> == 实例 2 == 移除字符串左侧的换行符(\n): <sample title="" desc="" lang="php" hererun="1"> <?php $str = "nnnHello World!"; echo "Without ltrim: " . $str; echo "<br>"; echo "With ltrim: " . ltrim($str); ?> </sample> 上面代码的 HTML 输出如下(查看源代码): <sample title="" desc="" lang="php" hererun="1"> <!DOCTYPE html> <html> <body> Without ltrim: Hello World!<br>With ltrim: Hello World! </body> </html> </sample> 上面代码的浏览器输出如下: <sample title="" desc="" lang="php" hererun="1"> Without ltrim: Hello World! With ltrim: Hello World! </sample> [[:分类:PHP字符串函数参考手册]]
返回至“
Func string ltrim
”。
上一节:
Func_string_localeconv
下一节:
Func_string_md5