如何删除 PHP 字符串的第一个字符?
删除 PHP 字符串第一个字符,代码如下−
示例
<?php $str = "Test"; echo "Before removing the first character = ".$str; $res = substr($str, 1); echo "
After removing the first character = ".$res; ?>
输出
将生成以下输出 −
Before removing the first character = Test After removing the first character = est
示例
我们现在来看另一个示例
<?php $str = "Demo"; echo "Before removing the first character = ".$str; $res = ltrim($str, 'D'); echo "
After removing the first character = ".$res; ?>
输出
将生成以下输出−
Before removing the first character = Demo After removing the first character = emo
广告