關於ltrim()函數解決方案

來源:互聯網
上載者:User
關於ltrim()函數
各位php大俠,請問一下,關於ltrim()函數,我得不到自己想要的結果,是為什麼呢?幫忙看一下代碼啊

$str1="E:/xmapp/htdocs/mycode/mycode/cms/";
$str2="E:/xmapp/htdocs/";
echo ltrim($str1,$str2)."
";

運行代碼輸出結果為:
ycode/mycode/cms/
預期代碼輸出結果為;
mycode/mycode/cms/

第二段代碼:

$str3="e:/hell/ab/mycode/cms";
$str4="e:/hell/ab/";
echo ltrim($str3,$str4)."
";


運行代碼輸出結果為:
mycode/cms
預期代碼輸出結果為;
mycode/cms



各位:為什麼第一段代碼的預期和實際輸出結果不同,而第二段的預期和實際是一樣的(註:這兩段代碼單獨運行,沒有摻雜其他代碼)


------解決方案--------------------
真不知你的語文老師是怎麼教你的?

參數 charlist 規定從字串中刪除哪些字元
注意是 字元,不是 字串

如果你不懂中文,那麼你也該懂點英文吧
Strip whitespace (or other characters) from the beginning of a string
Strip 剝去
whitespace (or other characters) 空白(或其它字元)
from the beginning of a string 從一個字串的開頭

charlist 字元列表
你還需要學習如何從函數原型上瞭解函數的用法

對於 ltrim($str1,$str2)
將對 $str1 進行掃描,逐個刪去出現在 $str2 中的字元,直到出現不在 $str2 中的字元為止
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.