我們在學習1.PHP函數explode的格式如下:
array explode(string separator, string string,[int limit]);
2.參數中的separator為分隔字元,string為待分割的字串,limit為返回的數組中元素的最大個數。
PHP函數explode的具體使用執行個體:
- php
- $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
- ?>
- <html>
- <head>
- <title>Test Explodetitle>
- head>
- <body>
- php
- $peoples = file($DOCUMENT_ROOT.'/test/03/people.txt');
- $countcount = count($peoples);
- if ($count == 0) {
- echo 'NO peoples pending. Please try again later.';
- }
- for ($i = 0; $i < $count; $i++) {
- $line = explode("t", $peoples[$i]);
- echo '<font color=red>'.$line[0].'font>';
- echo '<font color=blue>'.$line[1].'font>';
- echo '<font color=green>'.$line[2].'font>';
- echo '<br />';
- }
- ?>
- body>
- 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為待分割的字串,...