PHP若何去掉最初一个字符?
正在PHP中能够应用“rtrim()”函数去掉最初一个字符,该函数用于删除了字符串结尾的空缺字符或许其它字符,其语法是“rtrim(str,char) ”,其参数str示意要操作的字符串,参数char示意要去除了的字符。
应用典范榜样
<?php $text = "\t\tThese are a few words :) ... "; $binary = "\x09Example string\x0A"; $hello = "Hello World"; var_dump($text, $binary, $hello); print "\n"; $tri妹妹ed = rtrim($text); var_dump($tri妹妹ed); $tri妹妹ed = rtrim($text, " \t."); var_dump($tri妹妹ed); $tri妹妹ed = rtrim($hello, "Hdle"); var_dump($tri妹妹ed); // 删除了 $binary 结尾的 ASCII 码管制字符 // (包罗 0 - 31) $clean = rtrim($binary, "\x00..\x1F"); var_dump($clean); ?>
以上例程会输入:
string(32) " These are a few words :) ... " string(16) " Example string " string(11) "Hello World" string(30) " These are a few words :) ..." string(26) " These are a few words :)" string(9) "Hello Wor" string(15) " Example string"
保举教程:《PHP教程》
以上就是PHP若何去掉最初一个字符?的具体内容,更多请存眷资源魔其它相干文章!
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!