Skip to content

Instantly share code, notes, and snippets.

@johnsonch
Created April 15, 2015 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsonch/2f9f65f5b06aaa55cad4 to your computer and use it in GitHub Desktop.
Save johnsonch/2f9f65f5b06aaa55cad4 to your computer and use it in GitHub Desktop.
match_all_class_example.php
<?php
$string = 'My lovely gloves are lost in the clover, Love.';
$result = preg_match_all('/(\w*lo\w*)/i', $string, $matches);
if ($result == true) {
print "Found $result matches<br />";
}
else {
print 'Didn\'t find a match<br />';
}
$match_results = $matches[0];
foreach($match_results as $match){
echo $match."<br/>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment