<html>
<body>
$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 ) )