PHP中ltrim 函式的用法與例項講解

2022-09-26 05:57:10 字數 1032 閱讀 4321

php ltrim()ohqfxeo 函式

例項移除字串左側的字元:

<?php $str = 程式設計客棧"hello world!";

echo $str . "

"; echo ltrim($str,"hello");

?>

定義和用法

ltrim()函式移除字串左側的空白字元或其他預定義字元。

相關函式:

語法程式設計客棧ltrim( _string,charlist_ )

例項 1

移除字串左側的空格:

<?php $str = " hello world!";

echo "without ltrim: " . $str;

echo "

"; echo "with ltrim: " . ltrim($str);

?>

上面**的 html 輸出如下(檢視源**):

without ltrim: hello world!

with ltrim: hello world!

上面**的瀏覽器輸出如下:

without ltrim: hello world! 

with ltrim: hello world!

例項 2

移除字串左側的換行符(\n):

<?php $str = "nnnhello world!";

echo "without ltrim: " . $str;

echo "

程式設計客棧》";

echo "with ltrim: " . ltrim($str);

?>

上面**的 html 輸出如下(檢視源**):

without ltrim:

hello world!

with ltrim: hello world!

上面**的瀏覽器輸出如下:

without ltrim: hello world! 

with ltrim: hello world!

總結

Oracle中ltrim的用法

用法 declare a varchar 100 b varchar 100 begin a aaaabbbbbccccc b ltrim a,a dbms output.put line b end 解釋 從a這個字串中尋找與 a 一樣的字元 從左邊開始 當遇到與 a 不一致的字元,就停止,所以,...

Oracle中ltrim的用法

用法 declare a varchar 100 b varchar 100 begin a aaaabbbbbccccc b ltrim a,a dbms output.put line b end 解釋 從a這個字串中尋找與 a 一樣的字元 從左邊開始 當遇到與 a 不一致的字元,就停止,所以,...

PHP中is 函式用法

php中is 函式用法 is a 如果物件屬於該類或該類是此物件的父類則返回true is array 檢測變數是否是陣列 is bool 檢測變數是否是布林型 is callable 檢測引數是否為合法的可呼叫結構 is dir 判斷給定檔名是否是乙個目錄 is double is float 的...