The difference between explode and split in php

WBOY
Release: 2016-07-25 09:10:16
Original
910 people have browsed it
  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.



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!