Home  >  Article  >  Backend Development  >  The difference between explode and split in php

The difference between explode and split in php

WBOY
WBOYOriginal
2016-07-25 09:10:16922browse
  1. $test = end(explode('.', 'abc.txt'));
  2. echo $test;//output txt
Copy the code

and replace it with:

  1. $test1 = end(split('.','abc.txt'));
  2. echo $test1;//no output
Copy the code

use split The correct approach is: add escape symbols

  1. $test1 = end(split('.','abc.txt'));
  2. echo $test1;//output txt
Copy code

Remarks : The "." symbol is a keyword in regular expressions, so split is invalid, but explode is valid.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn