Get your own PHP server Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<?php
$str = "The rain in SPAIN falls mainly on the plains.";
$pattern = "/ain/i";
if(preg_match_all($pattern, $str, $matches)) {
  print_r($matches);
}
?>
</body>
</html>
Array
(
  [0] => Array
    (
      [0] => ain
      [1] => AIN
      [2] => ain
      [3] => ain
    )
)