如何爆炸一个字符串忽略分隔符的情况?

时间:2016-04-25 12:51:05

标签: php string explode case-insensitive

我有以下代码:

$string = "zero Or one OR two or three";
print_r(explode("or", $string));

现在,这导致:

Array ( [0] => zero Or one OR two [1] => three ) 

但我想忽略分隔符的情况,因此它适用于OrOR,...我的结果是:

Array ( [0] => zero [1] => one [2] => two [3] => three ) 

我该怎么做?

1 个答案:

答案 0 :(得分:1)

使用preg_split()

CREATE TRIGGER trMyTable_Update ON parent AFTER UPDATE 

 AS

    IF not exists (select 1 from deleted)

       return

    if exists (select 1 from deleted where SEARCHID IS NOT NULL)
      AND (UPDATE(SEARCHID) OR UPDATE(SEARCHID))  -- attempt to change existing values

     begin

         raiserror('You can not change values in SEARCHID or ANYOTHER once they were saved!',16,1)

         rollback

   end 

输出:

$string = "zero Or one OR two or three";
$keywords = preg_split("/or/i", $string);
echo '<pre>';print_r($keywords);echo '</pre>';