如何刪除 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP