如何在忽略分隔符大小写的情况下分解字符串?
How to explode a string ignoring the case of the delimiter?
我有以下代码:
$string = "zero Or one OR two or three";
print_r(explode("or", $string));
现在这导致:
Array ( [0] => zero Or one OR two [1] => three )
但我想忽略定界符的大小写,因此它适用于 Or
、OR
,...我的结果是:
Array ( [0] => zero [1] => one [2] => two [3] => three )
我该怎么做?
$string = "zero Or one OR two or three";
$keywords = preg_split("/or/i", $string);
echo '<pre>';print_r($keywords);echo '</pre>';
输出:
Array
(
[0] => zero
[1] => one
[2] => two
[3] => three
)
我有以下代码:
$string = "zero Or one OR two or three";
print_r(explode("or", $string));
现在这导致:
Array ( [0] => zero Or one OR two [1] => three )
但我想忽略定界符的大小写,因此它适用于 Or
、OR
,...我的结果是:
Array ( [0] => zero [1] => one [2] => two [3] => three )
我该怎么做?
$string = "zero Or one OR two or three";
$keywords = preg_split("/or/i", $string);
echo '<pre>';print_r($keywords);echo '</pre>';
输出:
Array
(
[0] => zero
[1] => one
[2] => two
[3] => three
)