分析PHP函數explode如何將字串轉換為數組_PHP教程

來源:互聯網
上載者:User
我們在學習1.PHP函數explode的格式如下:

array explode(string separator, string string,[int limit]);

2.參數中的separator為分隔字元,string為待分割的字串,limit為返回的數組中元素的最大個數。

PHP函數explode的具體使用執行個體:

 
  1. php
  2. $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
  3. ?>
  4. <html>
  5. <head>
  6. <title>Test Explodetitle>
  7. head>
  8. <body>
  9. php
  10. $peoples = file($DOCUMENT_ROOT.'/test/03/people.txt');
  11. $countcount = count($peoples);
  12. if ($count == 0) {
  13. echo 'NO peoples pending. Please try again later.';
  14. }
  15. for ($i = 0; $i < $count; $i++) {
  16. $line = explode("t", $peoples[$i]);
  17. echo '<font color=red>'.$line[0].'font>';
  18. echo '<font color=blue>'.$line[1].'font>';
  19. echo '<font color=green>'.$line[2].'font>';
  20. echo '<br />';
  21. }
  22. ?>
  23. body>
  24. html>

希望廣大學習愛好者們通過本文所介紹的PHP函數explode的使用樣本,能夠基本弄清PHP函數explode的使用方法。


http://www.bkjia.com/PHPjc/446337.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446337.htmlTechArticle我們在學習 1.PHP函數explode的格式如下: array explode(string separator, string string,[int limit]); 2.參數中的separator為分隔字元,string為待分割的字串,...

  • 聯繫我們

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