Analyze how the PHP function explode converts a string to an array. We are learning 1. the format of the PHP function explode is as follows: arrayexplode (stringseparator, stringstring, [intlimit]); 2. the separator in the parameter is the separator, and the string is the string to be split. 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.
Lifecycle 1. 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, and the string is the string to be split ,...