【发布时间】:2016-03-18 20:57:16
【问题描述】:
我正在尝试引爆一个字符串,但我需要它只在最后一个'and' 而不是每个'and' 上引爆。有没有办法做到这一点?
<?php
$string = "one and two and three and four and five";
$string = explode(" and ", $string);
print_r($string);
?>
结果:
数组([0] => 一[1] => 二[2] => 三[3] => 四[4] => 五)
需要结果:
数组([0] => 一二三四 [1] => 五)
【问题讨论】:
-
@chris85 我想也许有一个预建的功能。我想我会编写自己的函数来完成它。