Skip to content

Instantly share code, notes, and snippets.

@danjordan
Forked from davestevens/admin.php
Created June 9, 2011 09:40
Show Gist options
  • Save danjordan/1016429 to your computer and use it in GitHub Desktop.
Save danjordan/1016429 to your computer and use it in GitHub Desktop.
Example of preg_match
<?php
/* test regex */
$input = array(
'admin/',
'mens-books',
'admin/foo',
'foo/bar',
'min',
'admin'
);
$regex = '/^(?!admin\/)/';
foreach ($input as $in) {
echo $in . ' - ';
if(preg_match($regex, $in)) {
echo 'Match';
} else {
echo 'No Match';
}
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment