PHP case-insensitive explode()

前端 未结 3 1083
星月不相逢
星月不相逢 2021-01-17 13:39

I have the following code:

explode(\"delimiter\", $snippet);

But I want that my delimiter is case-insensitive.

3条回答
  •  孤独总比滥情好
    2021-01-17 14:23

    Just use preg_split() and pass the flag i for case-insensitivity:

    $keywords = preg_split("/your delimiter/i", $text);
    

    Also make sure your delimiter which you pass to preg_split() doesn't cotain any sepcial regex characters. Otherwise make sure you escape them properly or use preg_quote().

提交回复
热议问题