php字串截取substr函數簡介

來源:互聯網
上載者:User
  1. substr(php is very good language,4,5);
  2. 輸出為 is ve;
複製代碼

1,當start>str的長度,則返回為();

  1. substr(php is very good language,26,5);
  2. substr(php is very good language,4);
  3. 輸出為 (空白)
  4. 輸出為is v (表明start和langth都為4)
複製代碼

2,當start為負值,則從str末尾出開始讀起(*這時是從-1開始讀,而不是從0開始),

  1. substr(php is very good language,-4,5);
複製代碼

輸出為uage

3,當length為負值時,length代表的是從末尾開始讀,截取str的結束位置。

  1. substr(php is very good language,4,-5);
複製代碼

輸出為is very good lan

另外,explode()把函數字串分割為數組;strrev()把函數字串setlocalhost(content location)設定本地環境.content ,指定需要設定的情境資訊常量有(LC_ALL – 所有下屬的常量LC_COLLATE – 排列順序LC_CTYPE – 字元分類和轉換(例如:將所有的字元轉換成小寫或大寫形式)LC_MESSAGES – 系統資訊格式LC_MONETARY – 貨幣 / 通貨格式LC_NUMERIC – 數值格式LC_TIME – 日期和時間格式);location,設定國家地區,例如,chs.strftime()根據地區設定格式化本地時間/日期。

就介紹這些了,希望對大家有所協助。學php教程,就來程式員之家吧。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.