qvbrgw

首先来看下两个方法的定义: 

函数原型:array split (string $pattern, string $string [, int $limit]) 

函数原型:array explode ( string $separator, string $string [, int $limit]) 

初看没有啥差别,貌似功能都一样。

请注意两个函数的第一个参数string $pattern和string separator,一个是$pattern说明是正则字符串,一个是$separator是普通字符串。 


$test = end(explode(\'.\', \'abc.txt\')); 
echo $test;//output txt 

换成: 

test1 = end(split(\'.\',\'abc.txt\')); 

echo $test1;//no output 
 

用split的正确做法是:加转义符号 

$test1 = end(split(\'\.\',\'abc.txt\')); 
echo $test1;//output txt 

 

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2021-09-27
  • 2021-10-15
  • 2021-08-22
  • 2021-12-18
  • 2019-11-20
  • 2021-08-22
猜你喜欢
  • 2021-09-27
  • 2021-12-12
  • 2021-12-23
  • 2019-03-11
  • 2021-11-30
  • 2021-08-22
  • 2021-11-17
相关资源
相似解决方案