We are learning1. The format of PHP function explode is as follows:
Array explode (string separator, string, [int limit]);
2. The separator in the parameter is the separator, the string is the string to be split, and the limit is the maximum number of elements in the returned array.
Example of PHP function explode:
- <?php
- $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
- ?>
- <html>
- <head>
- <title>Test Explode</title>
- </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>
It is hoped that the majority of learning enthusiasts will use the PHP function explode example described in this article to find out how to use the PHP function explode.