2

I have the following code:

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

Right now this results in:

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

But I want to ignore the case of the delimiter so it works with Or, OR, ... and that my result is:

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

How can I do this?

Rizier123
  • 58,877
  • 16
  • 101
  • 156
Nabi
  • 764
  • 1
  • 10
  • 22

1 Answers1

1

Use preg_split()

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

Outputs:

Array
(
    [0] => zero 
    [1] =>  one 
    [2] =>  two 
    [3] =>  three
)
Pupil
  • 23,834
  • 6
  • 44
  • 66