Supremekhaoz Supremekhaoz - 2 years ago 274
PHP Question

PHP case-insensitive explode()

I have the following code:

explode("delimiter", $snippet);

But I want that my delimiter is case-insensitive.

Answer Source

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().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download