Analysis of how PHP function explode converts a string to an array _ PHP Tutorial

Source: Internet
Author: User
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:

 
 
  1. php
  2. $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
  3. ?>
  4. <html>
  5. <head>
  6. <title>Test Explode title>
  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>

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 ,...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.